GeofencingClient

public interfaceGeofencingClientimplementsHasApiKey<Api.ApiOptions.NoOptions>

The main entry point for interacting with geofencing. In order to obtain an instance of this class, seeLocationServices.

In order to use most geofencing APIs, clients are required to holdManifest.permission.ACCESS_FINE_LOCATION and Manifest.permission.ACCESS_BACKGROUND_LOCATION.

Public Method Summary

abstract Task<Void>
addGeofences(GeofencingRequest request,PendingIntent pendingIntent)
Adds all geofences from the givenGeofencingRequest.
abstract Task<Void>
removeGeofences(List<String> requestIds)
Removes geofences by their request IDs.
abstract Task<Void>
removeGeofences(PendingIntent pendingIntent)
Removes all geofences associated with givenPendingIntent.

Public Methods

public abstract Task<Void>addGeofences(GeofencingRequest request,PendingIntent pendingIntent)

Adds all geofences from the givenGeofencingRequest. Geofences are uniquely identified by the request ID set in Geofence.Builder.setRequestId(String)and any geofence added here will replace any prior geofence with the same ID. All geofences registered here will use the givenPendingIntent to report their transitions. When receiving transitions, GeofencingEvent.fromIntent(Intent)may be used to retrieve information about the transition.

ThePendingIntent passed in here must be mutable (ie, explicitly marked withPendingIntent.FLAG_MUTABLE on Android S+).

Geofences are automatically removed when the client application is reset (when the client application is upgraded or removed, or the user force-restarts or force-quits it), or if the pending intent is canceled.

If this API fails, referenceGeofenceStatusCodes for possible errors. Clients are encouraged to only add one geofence at a time if they need to recover or identify individual failures.

public abstract Task<Void>removeGeofences(List<String> requestIds)

Removes geofences by their request IDs.

public abstract Task<Void>removeGeofences(PendingIntent pendingIntent)

Removes all geofences associated with givenPendingIntent.

PendingIntent equality can be more complex than expected, please see thePendingIntent documentation for further information.