requestLocationUpdates minTime parameter purpose

android, gps, locationmanager

Solution

The minTime parameter doesn't fulfill its purpose, not even as a hint (Yea, a hint to 30 minutes update rate leads to more than update a second...). What does it do, then?

From Jellybean onwards devices must observe the `minTime` parameter, so it does have a purpose (now).

Is there any other way to do it? I don't want the GPS to be enabled all the time because it will consume my battery too fast. Maybe I could schedule alarms repeating each 30 minutes, and call requestSingleUpdate?

Yes, use a Handler to request one update with `requestSingleUpdate()` every 30 minutes.

I've tackled this before in a previous question, let me know if the code in that answer helps and if you have any questions it doesn't address.

Problem

I'm creating an application (For educational purposes) which records the user's location every 30 minutes, and enables the user the view all the locations on the map. I don't want updates to be more frequent than 30 minutes, but they are. This is how I call `requestLocationUpdates`: ``` locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 60 * 1000, 0, pe); ``` Now, the documentation clearly says: The elapsed time between location updates will never be less than minTime But I did see some answers here on SO stating differently (This answer, for example). It seems like I'm getting updates whenever they are available from the GPS. The GPS icon never turns off and the updates rate becomes greater than 1 update/second. So I have 2 questions here: - The `minTime` parameter doesn't fulfill its purpose, not even as a hint (Yea, a hint to 30 minutes update rate leads to more than update a second...). What does it do, then? - Is there any other way to do it? I don't want the GPS to be enabled all the time because it will consume my battery too fast. Maybe I could schedule alarms repeating each 30 minutes, and call `requestSingleUpdate`?

Original source

Related problems