2

Have gone through other SO posts on the same topic, and am stuck up deciding between the following approaches : Thread 1 versus Thread 2 versus simple onLocationUpdate()

Can someone please help me with the pros and cons of all these. I need updates every 30 seconds ; and I thought using requestSingleUpdate() with AlarmManager will not be accurate (since it has to re-initialize the process), and more battery consuming. But the threads seem to say the opposite.

I also have a geofence code in my app - will giving a large poll value affect that code too ?

Thanks !

Community
  • 1
  • 1
zombie
  • 265
  • 7
  • 16

1 Answers1

0

Note that the two threads you reference need fixes every 5 or 10 minutes. You are looking for every 30 seconds. My rough experience is that you are likely to need 30-60 seconds to get a fresh fix each time you turn on GPS, the upshot being that every 30 seconds is probably not that different from running it continuously.

But if you can talk yourself in to getting a fix every few minutes, then the rough strategy we settled on was enable gps, if you get a fix within 1 minute, use about the 10th one you get (you get them once per second once gps starts running) as there was clearly some accuracy advantage in some phones doing this, if you don't get a fix within 1 minute, turn off, give up and try again at the next interval. AlarmManager is a great way to time these as it will wake the phone up out of sleep so you won't miss any of your fix intervals.

mwengler
  • 2,738
  • 1
  • 19
  • 32