0

I downloaded the GeoDetection.zip file for trying out location based geofencing using the Google Play Services API that is available from the developer android website from the following link:

http://developer.android.com/training/location/geofencing.html

but when i tried to add geo fences using this app, i constantly get the error GEOFENCE_NOT_AVAILABLE

i tried to check what this error means, and i found that if location access is not available that is when i should get this message, but i checked the Location Services section on my phone and i saw that all the Location provides GPS/Wifi Location are all enabled. I am also connected to WIFI successfully. Not sure why i still get the message.

Any body else encounter this issue?..if so, do you have a fix that i could try?

Any other suggestions?.. i tried a lot of options to make sure it is capturing all the options, but there is isn't much debug information for me to proceed any further.

Thanks in advance

user2052129
  • 231
  • 4
  • 11
  • did you make sure that all of the pre-reqs for geofencing were met on your device? [google play services](http://developer.android.com/google/play-services/setup.html) – dudebrobro Aug 06 '13 at 15:32
  • yes, i did . In the code , i do see that it was able to successfully connect to Google Play Services SDK as well and had followed all the Steps in the Set up on my ADT environment. I am currently attempting this on my Samsumg Galaxy S4 which is running Android 4.2.2 (Jelly Bean). Not sure what the issue is .. – user2052129 Aug 06 '13 at 15:44
  • I restarted my Android Mobile Device and now it worked. I got the geofences added and also received notifications when i entered one of the geo fences as well. I guess it was all about my device. But at least its good to know that this could happen. – user2052129 Aug 06 '13 at 18:28
  • Keep in mind that there are several situations in which you'll need to re-register geofences. Please see [my answer to a related question](https://stackoverflow.com/questions/44323848/geofence-triggering-procedure-explanation-needed/50864092#50864092) for more information. – Michael Krause Jul 17 '18 at 19:57

2 Answers2

0

Are you requesting the FINE_LOCATION permission? Remember on Android 6 and above you have to handle the permissions at run-time too.

MrChaz
  • 1,065
  • 1
  • 8
  • 17
0

The above error, GEOFENCE_NOT_AVAILABLE is an expected error code, to let you know that the location adapter is off and location (and geofence) will NOT be tracked anymore.

Once available again, your geofences will be active and you will get the desired callback.

Few Reasons why the triggers aren't happening :

  1. Check if your expiry timestamp that you set in your geofence request, is still valid.
  2. Did your device get restarted ? If yes, you need to re-register fences. (Refer documentation : Re-register geofences only when required documentation)
  3. Is your location, set to High Accuracy mode in Device settings ? When you re-register your fences, you should un-register them first and then only re-register.
  4. Open Google maps and check if it's showing the right location.
  5. Is Battery Optimisation on for your device ? This will delay geofence triggers
  6. Is you app whitelisted for background operations (Happens in some Chinese OEM's)
Mayuri Khinvasara
  • 1,437
  • 1
  • 16
  • 12