Skip to main content

UserActivityModule

Class

Exposes the user's current mode of action (e.g. stationary, walking) and posture (e.g. standing, sitting) to Lens developers.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Since Lens Scripting v380

Exposes the user's current mode of action (e.g. stationary, walking) and posture (e.g. standing, sitting) to Lens developers. Accessible via require('LensStudio:UserActivityModule').

Index

Example

@component
export class ActivityExample extends BaseScriptComponent {
private activityModule: UserActivityModule = require('LensStudio:UserActivityModule');
onAwake() {
this.activityModule.onUserActivityChanged.add((modeOfAction, accuracy) => {
print("New mode of action: " + modeOfAction + ", accuracy: " + accuracy);
});
}
}

Extends

Properties

modeOfAction

readonly modeOfAction: ModeOfAction

SPECS

The current activity state. Use this to initialize Lens state on launch; use UserActivityModule.onUserActivityChanged to react to subsequent changes.

Since

Lens Scripting Version 380


name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


onPostureChanged

readonly onPostureChanged: event1<Posture, void>

SPECS

Callback for change in posture. Event to notify when user changes posture.

Param

posture

The current posture UserActivityModule.Posture.

Since

Lens Scripting Version 380


onUserActivityChanged

readonly onUserActivityChanged: event2<ModeOfAction, number, void>

SPECS

Callback for change in user activity. Event to notify when user changes activity.

Param

activity

The current activity state UserActivityModule.ModeOfAction.

Param

accuracy

The accuracy of the activity detected (between 0 and 1).

Since

Lens Scripting Version 380


posture

readonly posture: Posture

SPECS

The current posture. Use this to initialize Lens state on launch; use UserActivityModule.onPostureChanged to react to subsequent changes.

Since

Lens Scripting Version 380


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier


velocity

readonly velocity: number

SPECS

The current speed of the device in m/s.

Since

Lens Scripting Version 380

Methods

getTypeName()

static getTypeName(): TypeName<UserActivityModule>

SPECS

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<UserActivityModule>

Since

Lens Scripting Version 380

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Asset.isSame

Nested types

Enumerations

EnumerationDescription
ModeOfActionAn enumeration describing which activity is currently performed by the user.
PostureAn enumeration describing the user's current posture.