I am getting an error in the onAddGeofencesResult(int statusCode, String[] geofenceRequestIds)
callback with statusCode = 1000
.
I have my GP
Follow this official link to make broadcast for geofence.
https://developer.android.com/training/location/geofencing#java
"make sure that you call your Geofence.Builder and geofencingClient.addGeofences methods in onStart of your mainActivity after you have called googleApiClient.connect()."
then finally if you set location mode in settings i.e GPS or wifi only. You will get this error.(in case u are using emulator) Choose high accuracy mode and you will be able to add geofences. Hope this helps. Best Of Luck.
You get GEOFENCE_NOT_AVAILABLE
(code '1000') when user disagrees to "Use Google' location services" in Settings->Location->Mode:
To fix it:
First of all your phone must be compatible:
A compatible Android device that runs Android 2.2 or higher and includes Google Play Store.
Just to be sure, you need to have Google Play service installed correctly.
Sometimes, just restarting your phone can fix this problem.
Hope this help.
For my targetSdkVersion 28 and minSdkVersion 24, this is what worked for me on emulator running Pixel XL API 27:
I selected High accuracy
in the Settings -> Location -> Mode
. Originally it was set to Device only
.
This popped up a message to with Agree
and Disagree
options. I selected Agree
.
After that the error went away.
I tried the other option Battery Saving
. This also worked fine.
But when reverted back to Device only
, it started giving this error again.
So in case of emulator Location mode
should bet set to High accuracy
or Battery saving
.
On my actual device, which is a Nexus 6P device, it was already set to High accuracy
and I haven't checked it for Device only
.
Is a little later, but just now I had this issue. My guess is:
you are using any kind of fake GPS on your tests (Lockito, emulator, etc)?
I take some hours until I find out that the fake locations seems to disable the Geofence support! You cannot register or trigger a Geofence if you are not really in the location.
If you turn off the fake GPS,the Geofence support become enabled again.
Posting this answer since the settings in Android have changed a lot. I had this error twice when I was running a Nexus 5X emulator running API 28. I managed to solve it both times by doing the following:
Turn on your application again and adding geofences worked for me after I took these steps.
EDIT: I ran into this issue again a few months later, sometimes the emulator is stubborn and does not actually turn on location accuracy correctly to allow Google's Geofence API to recognise it is turned on. I had turn 'Improve Location Accuracy' on and off at least 10 times before location accuracy worked.