Summary: Constants | Methods | Inherited Methods | [Expand All]
public final class

# DetectedActivityFence

extends Object

java.lang.Object
↳ | com.google.android.gms.awareness.fence.DetectedActivityFence

## Class Overview

Use this class to create activity-based fences.

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

## Summary

Constants
int | IN_VEHICLE | The device is in a vehicle, such as a car.
int | ON_BICYCLE | The device is on a bicycle.
int | ON_FOOT | The device is on a user who is walking or running.
int | RUNNING | The device is on a user who is running.
int | STILL | The device is still (not moving).
int | TILTING | The device angle relative to gravity has changed significantly.
int | UNKNOWN | Unable to detect the current activity.
int | WALKING | The device is on a user who is walking.

Public Methods
static AwarenessFence | during(int... activityTypes) This fence is in the `TRUE` state when the user is currently engaged in one of the specified `activityTypes`, and `FALSE` otherwise.
static AwarenessFence | starting(int... activityTypes) This fence is momentarily (about 5 seconds) `TRUE` when the user begins to engage in one of the `activityTypes` and the previous activity was not one of the values in `activityTypes`.
static AwarenessFence | stopping(int... activityTypes) This fence is momentarily (about 5 seconds) `TRUE` when the user stops one of the `activityTypes`, and transitions to an activity that is not in `activityTypes`.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Constants

#### public static final int IN_VEHICLE

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

Constant Value: 0 (0x00000000)

#### public static final int ON_BICYCLE

The device is on a bicycle.

Constant Value: 1 (0x00000001)

#### public static final int ON_FOOT

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

Constant Value: 2 (0x00000002)

#### public static final int RUNNING

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

Constant Value: 8 (0x00000008)

#### public static final int STILL

The device is still (not moving).

Constant Value: 3 (0x00000003)

#### public static final int TILTING

The device angle relative to gravity has changed significantly. This often occurs when a device is picked up, or a user who is sitting stands up.

Constant Value: 5 (0x00000005)

#### public static final int UNKNOWN

Unable to detect the current activity.

Constant Value: 4 (0x00000004)

#### public static final int WALKING

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

Constant Value: 7 (0x00000007)

## Public Methods

#### public static AwarenessFence during (int... activityTypes)

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

To use this method, your app must declare the `com.google.android.gms.permission.ACTIVITY_RECOGNITION` permission in AndroidManifest.xml, and the user must provide consent at runtime.

##### 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 fence is momentarily (about 5 seconds) `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 use this method, your app must declare the `com.google.android.gms.permission.ACTIVITY_RECOGNITION` permission in AndroidManifest.xml, and the user must provide consent at runtime.

##### 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 fence is momentarily (about 5 seconds) `TRUE` when the user stops one of the `activityTypes`, and transitions to an activity that is not in `activityTypes`.

To use this method, your app must declare the `com.google.android.gms.permission.ACTIVITY_RECOGNITION` permission in AndroidManifest.xml, and the user must provide consent at runtime.

##### Parameters

activityTypes | Collection of activity type constants. Valid values are the constants defined in this class.

##### Returns

- Awareness fence.