0

I'm writing an Android application that notifies the user when he enters a specific region. For this I used the Geofence API from Android.

I have tried Google's GeofenceDetection sample, and The application does not get notified at all.

I call addGeofences, and receive onAddGeofencesResult notification with statusCode 0, so all seems to be working fine, but when I walk (or drive) in and out of the geofence (with radius 5m or 50m) nothing happens.

I use Nexus4 and Eclipse - both updated to latest versions.

Why don't I get geofence notifications?

DuduArbel
  • 1,100
  • 1
  • 12
  • 25
  • Is the GPS receiver enabled in your device settings? Do you have a signal? There are numerous GPS test apps that will show you how good your fix is. Are you running any mock GPS app that could be overriding the real GPS provider? – Kevin Krumwiede Apr 21 '14 at 05:34
  • The GPS is working - I can get locations read from it, and the navigator works fine. I do not use mock locations – DuduArbel Apr 21 '14 at 05:43
  • can you share your Broadcast Receiver or InstentService class code??? – Pankaj Apr 21 '14 at 05:49
  • I'm running Google sample - http://developer.android.com/training/location/geofencing.html – DuduArbel Apr 21 '14 at 06:04

1 Answers1

0

I've found that the GeoFencing API never intelligently retrieves locations from the GPS hardware. The GeoFence API will observe the most accurate location available from the OS or if no location is currently available, it will cause a location to be calculated from Wifi / Cellular. (which sucks because cellular is wildly inaccurate and wifi is often unavailable)

So to get at all responsive or accurate results out of the Geofencing API you have to set up your Geofences and then poll the GPS hardware on an interval, not even doing anything with the result received, so that under the surface you are providing worthwhile data to the OS.

This behaviour is not documented- thanks Google!

stealthwang
  • 915
  • 6
  • 8