24

How can I determine all geofences registered for an application?

After registering GeoFences with LocationClient.addGeofences(),I waited for onAddGeofencesResuls()(which returned SUCCESS) and tried to use LocationClient.getTriggeringGeofences(intent) with the same intent I used for registration, but I only got null.

Simon
  • 14,407
  • 8
  • 46
  • 61
Flo
  • 1,469
  • 1
  • 18
  • 27

3 Answers3

10

I assume you are trying to compare the registered geofences with the ones that you have persisted in your own database.

I tried to do that as well with my app, but it seems like the API hints that this is not the way to go. So what I do now is just to simply register geofences, it will automatically replace those that I have registered before. And when some that I have registered fires, and I am supposed to remove them, I will remove them in the firing Intent.

Another possibility is to register all the geofences to have 24 hours time limit, and have the code register the geofences at least once everyday.

Phuah Yee Keat
  • 1,572
  • 1
  • 17
  • 17
3

getTriggeringGeofences() only returns Geofences that triggered a transition last time. That's why it returns null if no transition occurrs. Refer to the documentation: http://developer.android.com/reference/com/google/android/gms/location/LocationClient.html#getTriggeringGeofences%28android.content.Intent%29

Miloš Černilovský
  • 3,846
  • 1
  • 28
  • 30
-1
GeofencingRequest.getGeofences();

This method return a list of geofences

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 26 '23 at 10:53