Error adding geofences in Android (status code 1000)

后端 未结 11 1121
孤城傲影
孤城傲影 2020-12-01 17:52

I am getting an error in the onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) callback with statusCode = 1000.

I have my GP

相关标签:
11条回答
  • 2020-12-01 18:16

    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.

    0 讨论(0)
  • 2020-12-01 18:17

    You get GEOFENCE_NOT_AVAILABLE (code '1000') when user disagrees to "Use Google' location services" in Settings->Location->Mode: enter image description here

    To fix it:

    • go to Settings->Location->Mode
      enter image description here
    • set "Device only (Use GPS to determine your location)"
    • set any other option to get the popup (e.g. "High accuracy (Use GPS, Wi-Fi and mobile networks to determine location")
    • dialog ""Use Google' location services" is shown
    • choose "Agree"
    0 讨论(0)
  • 2020-12-01 18:18

    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.

    0 讨论(0)
  • 2020-12-01 18:18

    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.

    0 讨论(0)
  • 2020-12-01 18:21

    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.

    0 讨论(0)
  • 2020-12-01 18:25

    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:

    1. Turn off your application you are developing (don't let it be in the background)
    2. Go to Settings -> Security & Location -> Location -> Advanced -> Google Location Accuracy. Turn 'Improve Location Accuracy' off.

    1. Turn on 'Improve Location Accuracy'

    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.

    0 讨论(0)
提交回复
热议问题