Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how long minimum distance should provide for android locationmanager?

In android location manager, we should provide minimum distance change for update and minimum time between update. Thus I need to know how long minimum distance range and minimum time between should I provide to know current location as soon as possible?

like image 973
PPShein Avatar asked Nov 14 '25 09:11

PPShein


1 Answers

Although putting both values as 0 will give you the fastest but will consume lot of resources and thus lot of battery power will be lost. For choosing the appropriate value you have to see your needs first as the documentation says:

The location update interval can be controlled using the minTime parameter. The elapsed time between location updates will never be less than minTime, although it can be more depending on the Location Provider implementation and the update interval requested by other applications.

Moreover the documentation of requestLocationUpdate function suggests to select your values as follows:

It says:

Choosing a sensible value for minTime is important to conserve battery life. Each location update requires power from GPS, WIFI, Cell and other radios. Select a minTime value as high as possible while still providing a reasonable user experience.

To be specific:

If your application is not in the foreground and showing location to the user then your application should avoid using an active provider (such as NETWORK_PROVIDER or GPS_PROVIDER), but if you insist then select a minTime of 5 * 60 * 1000 (5 minutes) or greater. If your application is in the foreground and showing location to the user then it is appropriate to select a faster update interval.

As the minDistance parameter is concerned:

If it is greater than 0 then the location provider will only send your application an update when the location has changed by at least minDistance meters, AND at least minTime milliseconds have passed. However it is more difficult for location providers to save power using the minDistance parameter, so minTime should be the primary tool to conserving battery life.

Hope this helps.

like image 104
Shobhit Puri Avatar answered Nov 17 '25 10:11

Shobhit Puri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!