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?
Reminder: To use the Geolocation API, you must enable billing on each of your projects and include an API key with all API or SDK requests. The Geolocation API uses a pay-as-you-go pricing model.
To do so, choose a campaign and then go to its Settings page. You can choose from a number of geo-targeting options such as Country, State, Zip Code, Radius and City. You can set up geofencing on the ads displayed on google search results, the display network and YouTube.
If you only use cellular network, the location accuracy is lower, than the accuracy of wi-fi or gps (if you open Google Maps, the blue circle is estimation of your current position - if you only use 3GP, the circle can have radius of even hundreds of meters).
Last days I am working on an app using Geofences and I figured out the following: IMHO the geofence entry is triggered only if ALL this "location estimation circle" is inside the geofence radius, i.e. if there is 100 % chance that you entered the geofence. So it depends on how big radius you set. If you set only 10 metres, it will probably work only with GPS, never with 3GP. For 3GP you will have to set radius like 1000 metres.
Wifi is used to help track your location. Using wifi signals and cell signals to triangulate your position is a more power efficient solution than having your GPS running constantly. Additionally it works in situations where GPS wouldn't such as heavy multipath areas and indoors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With