1

I'm developing a location logging application that saves a phone location each second.
I've implemented a service that subscribes to LocationManager updates:

HandlerThread thread = new HandlerThread("LocationServiceHandler");
locationManager.requestLocationUpdates(GPS_PROVIDER, 
    1000 /* milliseconds*/, 0 /* meters */, listener, thread.getLooper());

The service started by binding to an application context.
Application usually runs in a background and doesn't requires any user interaction.
Generally it works OK when I'm walking around my building - the service gets a new location+timestamp each second and stores it to a file located at external storage.
But when I'm getting to an open field away from a city, I found a 4-5 minutes gaps between records in a log file. I can say for sure that the phone wasn't in use at that moment and it was under the open sky, nothing visible was blocking a satellites. It happens irregularly, aprox once a hour and I can't reproduce this behavior at my office.
Any ideas, what might cause that? How can it be avoided?
The phone is Nexus S, Android 2.3.4

GetUsername
  • 1,057
  • 5
  • 18
  • 29

1 Answers1

0

Are you using a wakelock? The phone might go to sleep and you therefore misses locations. Otherwise it might just be the locationmanager that just don't give you the location since the 1000 ms is a best case scenario. Please see Update GPS Listener every 5 seconds answers.

Community
  • 1
  • 1
David Olsson
  • 8,085
  • 3
  • 30
  • 38
  • No, I'm not using a wakelock, but this can be checked easily. All I need is to start my app and don't touch a phone for... lets say a one hour – GetUsername Aug 19 '11 at 12:12
  • Sadly, but no, the phone is not putting a LocationManager to sleep. I've checked it this way: I've started the app, locked the phone screen and took a long walk (more then two hours). The phone was in my pocket and I didn't touch it at all. After that I've analyzed the log and found some 2 seconds gaps, which is not bothering me. Still can't reproduce a long 4-5 minutes intervals... – GetUsername Aug 20 '11 at 14:57