Android - How to retrieve list of registered geofences

Flo picture Flo · May 19, 2013 · Viewed 7.9k times · Source

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.

Answer

Phuah Yee Keat picture Phuah Yee Keat · Dec 11, 2013

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.