FoamyGuy
FoamyGuy

Reputation: 46856

Android Geofencing sample app only works if another app is open using GPS

I am working with the Geofence API Sample application I've got it running and seems to work alright. I did make the modifications to it to use BroadcastReceiver instead of the IntentService.

But I will only get the notifications if I have some other app open that is using GPS such as Maps, or GPS Tester app.

If I don't have one of those apps open and I walk into the geofence zone nothing happens. But as soon as I launch one of them I will get the notification within a few seconds.

Upvotes: 7

Views: 2527

Answers (2)

Pankaj
Pankaj

Reputation: 2110

Even I too had a struggle with getting Geofence notification as soon I entered Geofence or Exit the one.There were always delays in notifications until I found a really nice Location Library called little-fluffy-location-library which serves my purpose.Location updates will be broadcast to your app periodically.

According the Documentation it says that:

The library works by using Froyo's passive location listener (only possible with Android 2.2 and up, hence why it works best with it), which listens to location updates requested by other apps on your phone. The most accurate location is broadcast to your app approximately every 15 minutes. If a location update hasn't been received from another app for an hour, the library forces a location update of its own.

I think you should give a try with this Library and Let me know if it works for you!!

Upvotes: 2

FoamyGuy
FoamyGuy

Reputation: 46856

I ended up creating a service that forces the GPS to stay active by requesting location updates on a relatively quick interval.

While this is admittedly a poor work around for a "real" application. It worked for my purposes. In which I needed to be able to present a working proof of concept to an audience, which impeded my ability to use a geo points which were further spread out.

Upvotes: 3

Related Questions