synic
synic

Reputation: 26668

Best way to constantly monitor location

I want to monitor a user's location on a regular basis, like Google Latitude does. Something that would wake the phone up every X minutes, even if the app is currently not running, get the location, and send it to a server. This is something that the user will have to opt into.

Using LocationManager alone does not seem to be the way to go. I guess this is sort of a follow up question to this one: LocationManager updates every minute, consuming a lot of battery power

It seems like using a combination of AlarmManager and LocationManager would work.

What is the best way to do this?

Upvotes: 6

Views: 3093

Answers (2)

CommonsWare
CommonsWare

Reputation: 1006584

I've tried just using LocationManager for this and did not have much luck. Hence, I rolled a LocationPoller that, in conjunction with your own _WAKEUP alarms, should handle this scenario.

Upvotes: 3

FrinkTheBrave
FrinkTheBrave

Reputation: 3958

Have you looked into writing a service to handle this?

I would be a bit concerned about battery life though, so I'd make the 'X' configurable, if that's appropriate

Upvotes: 1

Related Questions