GeofencingEvent

  • GeofencingEvent represents events from the GeofencingClient API, including geofence transitions and monitoring errors.

  • You can create a GeofencingEvent object from an intent using the staticfromIntent method.

  • The class provides methods to retrieve error codes, transition types, triggering geofences, triggering location, and to check if an error occurred.

public classGeofencingEvent extendsObject

Represents an event from theGeofencingClient API. The event can be

  • A geofence triggering event generated when a geofence transition happens.
  • An error happens after geofences are registered and being monitored.

Public Method Summary

staticGeofencingEvent
fromIntent(Intent intent)
Creates aGeofencingEvent object from the given intent.
int
getErrorCode()
Returns the error code that explains the error that triggered the intent specified in fromIntent(Intent).
int
getGeofenceTransition()
Returns the transition type of the geofence transition alert.
List<Geofence>
getTriggeringGeofences()
Returns a list of geofences that triggered this geofence transition alert.
Location
getTriggeringLocation()
Gets the location that triggered the geofence transition.
boolean
hasError()
Whether an error triggered this intent.

Inherited Method Summary

From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
finalClass<?>
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()

Public Methods

public staticGeofencingEventfromIntent(Intent intent)

Creates aGeofencingEvent object from the given intent.

Parameters
intentthe intent to extract the geofencing event data from
Returns
  • aGeofencingEvent object ornull if the given intent isnull or doesn't contain geofencing event.

public intgetErrorCode()

Returns the error code that explains the error that triggered the intent specified in fromIntent(Intent).

Returns

public intgetGeofenceTransition()

Returns the transition type of the geofence transition alert.

Returns
  • -1 if the intent specified in fromIntent(Intent) is not generated for a transition alert; Otherwise returns the GEOFENCE_TRANSITION_ flags value defined inGeofence.

publicList<Geofence>getTriggeringGeofences()

Returns a list of geofences that triggered this geofence transition alert.

Returns
  • a list of geofences that triggered this geofence transition alert ornull if the intent specified in fromIntent(Intent) is not generated for a geofence transition alert

publicLocationgetTriggeringLocation()

Gets the location that triggered the geofence transition.

Returns
  • the location that triggered this geofence alert ornull if it's not included in the intent specified in fromIntent(Intent)

public booleanhasError()

Whether an error triggered this intent.

Returns

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-10-31 UTC.