DetectedActivityFence

public final class DetectedActivityFence extends Object

This class is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

Use this class to create activity-based fences.

Note: Values that indicate a changing state are momentarily FenceState.TRUE for about 5 seconds, then automatically revert to FenceState.FALSE.

Constant Summary

int IN_VEHICLE This constant is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.
int ON_BICYCLE This constant is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.
int ON_FOOT This constant is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.
int RUNNING This constant is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.
int STILL This constant is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.
int UNKNOWN This constant is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.
int WALKING This constant is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

Public Method Summary

static AwarenessFence
during(int... activityTypes)
This method is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.
static AwarenessFence
starting(int... activityTypes)
This method is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.
static AwarenessFence
stopping(int... activityTypes)
This method is deprecated. The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

Inherited Method Summary

Constants

public static final int IN_VEHICLE

This constant is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

The device is in a vehicle, such as a car.

Constant Value: 0

public static final int ON_BICYCLE

This constant is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

The device is on a bicycle.

Constant Value: 1

public static final int ON_FOOT

This constant is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

The device is on a user who is walking or running.

Constant Value: 2

public static final int RUNNING

This constant is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

The device is on a user who is running. This is a sub-activity of ON_FOOT.

Constant Value: 8

public static final int STILL

This constant is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

The device is still (not moving).

Constant Value: 3

public static final int UNKNOWN

This constant is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

Unable to detect the current activity.

Constant Value: 4

public static final int WALKING

This constant is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

The device is on a user who is walking. This is a sub-activity of ON_FOOT.

Constant Value: 7

Public Methods

public static AwarenessFence during (int... activityTypes)

This method is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

This fence is in the FenceState.TRUE state when the user is currently engaged in one of the specified activityTypes, and FenceState.FALSE otherwise.

To call this function, a different permission is required depending on your Android API level:

  • For Android 10 (API level 29) and later: android.permission.ACTIVITY_RECOGNITION permission
  • For Android 9 (API level 28) and earlier: com.google.android.gms.permission.ACTIVITY_RECOGNITION permission
Parameters
activityTypes Collection of activity type constants. Valid values are the constants defined in this class.
Returns
  • Awareness fence.

public static AwarenessFence starting (int... activityTypes)

This method is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

This fence is momentarily (about 5 seconds) FenceState.TRUE when the user begins to engage in one of the activityTypes and the previous activity was not one of the values in activityTypes.

To call this function, a different permission is required depending on your Android API level:

  • For Android 10 (API level 29) and later: android.permission.ACTIVITY_RECOGNITION permission
  • For Android 9 (API level 28) and earlier: com.google.android.gms.permission.ACTIVITY_RECOGNITION permission
Parameters
activityTypes Collection of activity type constants. Valid values are the constants defined in this class.
Returns
  • Awareness fence.

public static AwarenessFence stopping (int... activityTypes)

This method is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services release, as early as January 2027. There is no direct replacement.

This fence is momentarily (about 5 seconds) FenceState.TRUE when the user stops one of the activityTypes, and transitions to an activity that is not in activityTypes.

To call this function, a different permission is required depending on your Android API level:

  • For Android 10 (API level 29) and later: android.permission.ACTIVITY_RECOGNITION permission
  • For Android 9 (API level 28) and earlier: com.google.android.gms.permission.ACTIVITY_RECOGNITION permission
Parameters
activityTypes Collection of activity type constants. Valid values are the constants defined in this class.
Returns
  • Awareness fence.