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 i开发者_运维百科s the best way to do this?
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.
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
精彩评论