Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to constantly monitor location

Tags:

android

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?

like image 634
synic Avatar asked May 01 '11 15:05

synic


People also ask

Should I keep my location on all the time?

Conclusion. Enabling GPS uses zero extra power except when location services are actually being used. You'll use more power turning it on and off than just leaving it on all the time. There is no point in keeping your GPS on if you aren't using any app that utilizes it.

How do I share my location indefinitely on Google Maps?

Open the Find My app and choose the People tab. Select Start Sharing Location. Enter the name or number of the person you want to share your location with and tap Send. Select how for long you want to share your location, and tap OK.


2 Answers

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.

like image 67
CommonsWare Avatar answered Sep 22 '22 02:09

CommonsWare


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

like image 29
FrinkTheBrave Avatar answered Sep 23 '22 02:09

FrinkTheBrave