Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the Android Geofencing API?

Tags:

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 and getErrorCode(Intent) returns GEOFENCE_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:

  1. Does geofencing only work with WiFi enabled?

  2. Why doesn't the location provided by my 3G network work?

  3. Is this a bug in the sample code?

  4. Or is this my mistake?

like image 274
kylee Avatar asked May 27 '13 08:05

kylee


People also ask

Is Google geofencing API free?

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.

How do I use Google geofencing?

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.


2 Answers

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.

like image 157
Miloš Černilovský Avatar answered Sep 30 '22 00:09

Miloš Černilovský


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.

like image 24
Njall Avatar answered Sep 30 '22 00:09

Njall