问题
I do app with geofencing use and since I started to work with it I get to broadcastReceiver the transitions and when I turned off the GPS location I got an alert with code GEOFENCE_NOT_AVAILABLE and I started a service to reregister the geofences when I will turn on the GPS. Now I took a few days break and suddenly my broadcastReceiver doesn't get alerts when I turn off the GPS. I don't understand why? *when I enter/exit from location (like I defined in the geofences init) I trigger the alerts, the problem is just at the triggering of the GEOFENCE_NOT_AVAILABLE alert.
I will glad if anyone can help me
回答1:
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 :
- Check if your expiry timestamp that you set in your geofence request, is still valid.
Did you device get restarted ? If yes, you need to re-register fences. (Refer documentation : Re-register geofences only when required documentation)
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.
Open Google maps and check if its showing the right location.
来源:https://stackoverflow.com/questions/57413993/geofence-problem-in-triggering-geofence-not-available