Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error adding geofences in Android (status code 1000)

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

I have my GPS enabled and my WiFi. I also have Google Play Services and I am able to track my location and request updates. Why am I not able to add geofences? I am not able to add geofences even from the documentation sample app. I get the following Toast message:

"Add Geofences: Failure, error code 1000 GeofenceRequestIds=[1,2,1,2]"

From the documentation (statusCode 1000):

public static final int GEOFENCE_NOT_AVAILABLE

Geofence service is not available now. Typically this is because the user turned off location access in settings > location access.

Constant Value: 1000 (0x000003e8)

like image 641
Speed Demon Avatar asked Sep 29 '13 19:09

Speed Demon


People also ask

What are Android Geofences?

Geofencing is a location-based service that sends a notification to smartphone users who enter a defined geographic area. A geofence is a virtual barrier. Example: Some companies send promotions to customers' smartphones when they enter a store, mall or neighborhood.


5 Answers

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"
like image 161
Marian Paździoch Avatar answered Oct 22 '22 21:10

Marian Paździoch


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.

enter image description here

  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.

like image 38
MinistryOfChaps Avatar answered Oct 22 '22 22:10

MinistryOfChaps


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 took some hours until I found 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.

like image 38
Renascienza Avatar answered Oct 22 '22 22:10

Renascienza


I was getting the statusCode 1000 when i was trying to run this app on the emulator. The thing which fixed this was to go in Settings-> locations and access-> Check the enable wifi and gps option on the emulator and it will fix it

like image 5
Android2390 Avatar answered Oct 22 '22 21:10

Android2390


You actually gave the answer in your question: Geofence service is not available now. Typically this is because the user turned off location access in settings > location access.

I had this same issue, and just going to settings --> location and making sure I select the mode for high accuracy fixed this issue.

PS Device only mode is not good enough, it needs to be High accuracy mode.

Hope this helps.

like image 2
FiL0 Avatar answered Oct 22 '22 22:10

FiL0