How to know whether Geofences are available or not in app after adding geofences

170 Views Asked by At

I created an app with the geofencing concept. After testing the app is not triggering geofences efficiently, So I want to know whether geofences are available at that time or not in the app.

Anyone, please provide a code to know whether the geofences are available or not

How to know whether the geofences are available or not

1

There are 1 best solutions below

0
Mathias On

On Android, there is unfortunately no way to ask the system about which geofences you have previously created. You must therefor keep track of every geofence you have created yourself. I do this by writing data containing information about the geofence (lon, lat, accuracy, name etc.) to a text file so that I later can retrieve them when I need.


This is also necessary for another reason - your geofences can be cleared at various times, the most common being device reboot. You need to register a BroadcastReceiver that gets called by the system when a device starts up. In there you need to know what geofences you want to create and do that again.