I have been testing the new Google Play Geofencing service API.
I downloaded the sample code from the Android developers site. Next, I ran the example code on an Android device (Galaxy Note 2). I placed my office geo-position and radius to 10m, but when I walked to my office, nothing happened.
While running the sample code, one thing I have noticed is that when I am already inside the geofence range and then add the geofence to LocationClient
, nothing happens.
I had already read LocationClient
class documentation, and found the following paragraph:
In case network location provider is disabled by the user, the geofence service will stop updating, all registered geofences will be removed and an intent is generated by the provided pending intent. In this case,
hasError(Intent)
returns true andgetErrorCode(Intent)
returnsGEOFENCE_NOT_AVAILABLE
."
So I turned on WiFi, and was walking to my office (inside the geofence), and then I got notification "geofence entered".
I have the following questions:
Does geofencing only work with WiFi enabled?
Why doesn't the location provided by my 3G network work?
Is this a bug in the sample code?
Or is this my mistake?
NetworkLocationProvider
doesn't mean only wifi, its a tringualtion of Wifi and cell tower. That's pretty awful that geofence api doesn't work if user has turned off theNetwork Location
even if GPS is on (According to the documentation). – AdaoLocationManager
class is quite accurate though. – Adao