BeaconFence

  • BeaconFence allows for creating fences that detect nearby beacons with associated attachments.

  • Fences indicating a changing state, such as found or lost, are momentarily true for about 5 seconds before reverting to false.

  • The found method creates a fence that is true when a beacon of a specified type is detected.

  • The lost method creates a fence that is true when a beacon of a specified type is no longer detected.

  • The near method creates a fence that is true when a beacon of a specified type is found and not lost.

public final class BeaconFence 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 beacon fences.

The fences in this class support detecting nearby beacons that are associated with attachments, which are a triple of namespace, type, and content.

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

Public Method Summary

static AwarenessFence
found(Collection<BeaconState.TypeFilter> beaconTypes)
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
found(TypeFilter... beaconTypes)
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
lost(TypeFilter... beaconTypes)
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
lost(Collection<BeaconState.TypeFilter> beaconTypes)
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
near(TypeFilter... beaconTypes)
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
near(Collection<BeaconState.TypeFilter> beaconTypes)
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

Public Methods

public static AwarenessFence found (Collection<BeaconState.TypeFilter> beaconTypes)

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 FenceState.TRUE (about 5 seconds) when a beacon with the specified types is found.

To use this API, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and the user must provide consent at runtime.

Parameters
beaconTypes BeaconState.TypeFilter non-empty beacon types listing to scan for.
Returns
Throws
IllegalArgumentException when beaconTypes is null or empty

public static AwarenessFence found (TypeFilter... beaconTypes)

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 FenceState.TRUE (about 5 seconds) when a beacon with the specified types is found.

To use this API, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and the user must provide consent at runtime.

Parameters
beaconTypes BeaconState.TypeFilter non-empty beacon types listing to scan for.
Returns
Throws
IllegalArgumentException when beaconTypes is null or empty

public static AwarenessFence lost (TypeFilter... beaconTypes)

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 FenceState.TRUE (about 5 seconds) when a beacon with the specified types is lost.

To use this API, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and the user must provide consent at runtime.

Parameters
beaconTypes BeaconState.TypeFilter non-empty beacon types listing to scan for.
Returns
Throws
IllegalArgumentException when beaconTypes is null or empty

public static AwarenessFence lost (Collection<BeaconState.TypeFilter> beaconTypes)

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 FenceState.TRUE (about 5 seconds) when a beacon with the specified types is lost.

To use this API, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and the user must provide consent at runtime.

Parameters
beaconTypes BeaconState.TypeFilter non-empty beacon types listing to scan for.
Returns
Throws
IllegalArgumentException when beaconTypes is null or empty

public static AwarenessFence near (TypeFilter... beaconTypes)

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 evaluates to FenceState.TRUE if any of the specified types is found but not lost.

To use this API, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and the user must provide consent at runtime.

Parameters
beaconTypes BeaconState.TypeFilter non-empty beacon types listing to scan for.
Returns
Throws
IllegalArgumentException when beaconTypes is null or empty

public static AwarenessFence near (Collection<BeaconState.TypeFilter> beaconTypes)

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 evaluates to FenceState.TRUE if any of the specified types is found but not lost.

To use this API, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and the user must provide consent at runtime.

Parameters
beaconTypes BeaconState.TypeFilter non-empty beacon types listing to scan for.
Returns
Throws
IllegalArgumentException when beaconTypes is null or empty