class info
public final class BehaviorBarrier extends Object
Behavior barriers, including the beginning, ending, and keeping barriers of behaviors.

Constant Summary

TypeNameDesc
intBEHAVIOR_IN_VEHICLEThe user is driving.
intBEHAVIOR_ON_BICYCLEThe user is cycling.
intBEHAVIOR_ON_FOOTThe user is walking or running.
intBEHAVIOR_RUNNINGThe user is running.
intBEHAVIOR_WALKINGThe user is walking.
intBEHAVIOR_STILLThe user is still.
intBEHAVIOR_UNKNOWNIndicates that the current status of the user cannot be detected.

Note: Unknown behavior barriers cannot be registered.

Public Method Summary

Return typeMethod name
AwarenessBarrierpublic static AwarenessBarrier keeping(int… behaviorTypes)
AwarenessBarrierpublic static AwarenessBarrier ending(int… behaviorTypes)
AwarenessBarrierpublic static AwarenessBarrier beginning(int… behaviorTypes)

Constants

Constant
public static final int BEHAVIOR_IN_VEHICLE
The user is driving.
Constant Value: 0
Constant
public static final int BEHAVIOR_ON_BICYCLE
The user is cycling.
Constant Value: 1
Constant
public static final int BEHAVIOR_ON_FOOT
The user is walking or running.
Constant Value: 2
Constant
public static final int BEHAVIOR_RUNNING
The user is running.
Constant Value: 8
Constant
public static final int BEHAVIOR_WALKING
The user is walking.
Constant Value: 7
Constant
public static final int BEHAVIOR_STILL
The user is still.
Constant Value: 3
Constant
public static final int BEHAVIOR_UNKNOWN
Indicates that the current behavior of the user cannot be detected.

Note: Unknown behavior barriers cannot be registered.

Constant Value: 4

Public Methods

Method
public static AwarenessBarrier keeping(int… behaviorTypes)
Behavior barrier named keeping. After the barrier in a specified behavior status (excluding BEHAVIOR_UNKNOWN) is added, when a user is in the behavior status , the barrier status is TRUE and a barrier event is reported.
The android.permission.ACTIVITY_RECOGNITION permission must be added for Android 10 (API level 29) and later versions.
The com.huawei.hms.permission.ACTIVITY_RECOGNITION permission must be added for Android 9 (API level 28) and earlier versions.

Parameters  

Parameter nameParameter desc
behaviorTypesOne or more behavior type constants.

Return
 

Typedesc
AwarenessBarrierAwareness barrier.

Throws
 

Parameter nameParameter desc
IllegalArgumentExceptionThe behaviorTypes parameter is empty or invalid, or set to BEHAVIOR_UNKNOWN.
Method
public static AwarenessBarrier beginning(int… behaviorTypes)
Behavior barrier named beginning. After the barrier in a specified behavior status (excluding BEHAVIOR_UNKNOWN) is added, when a user is in the behavior status, the barrier status is TRUE and a barrier event is reported. After 5s, the barrier status changes to FALSE.
The android.permission.ACTIVITY_RECOGNITION permission must be added for Android 10 (API level 29) and later versions.
The com.huawei.hms.permission.ACTIVITY_RECOGNITION permission must be added for Android 9 (API level 28) and earlier versions.

Parameters  

Parameter nameParameter desc
behaviorTypesOne or more behavior type constants.

Return
 

Typedesc
AwarenessBarrierAwareness barrier.

Throws
 

Parameter nameParameter desc
IllegalArgumentExceptionThe behaviorTypes parameter is empty or invalid,or set to BEHAVIOR_UNKNOWN.
Method
public static AwarenessBarrier ending(int… behaviorTypes)
Behavior barrier named ending. After the barrier in a specified behavior status (excluding BEHAVIOR_UNKNOWN) is added, when a user stops the behavior, the barrier status is TRUE and a barrier event is reported. After 5s, the barrier status changes to FALSE.
The android.permission.ACTIVITY_RECOGNITION permission must be added for Android 10 (API level 29) and later versions.
The com.huawei.hms.permission.ACTIVITY_RECOGNITION permission must be added for Android 9 (API level 28) and earlier versions.

Parameters  

Parameter nameParameter desc
behaviorTypesOne or more behavior type constants.

Return
 

Typedesc
AwarenessBarrierAwareness barrier.

Throws
 

Parameter nameParameter desc
IllegalArgumentExceptionThe behaviorTypes parameter is empty or invalid,or set to BEHAVIOR_UNKNOWN.