문제

How often does android requests location updates? For example if you add a proximity alert to a location manager how often will it update the location?

In the documentation it says: "In case the screen goes to sleep, checks for proximity alerts happen only once every 4 minutes. This conserves battery life by ensuring that the device isn't perpetually awake"

But what if the screen doesn't go to sleep?

Thanks in advance

Mike

도움이 되었습니까?

해결책

In the LocationManager class, there is a method called requestLocationUpdates that can be called with different set of parameters. It "Registers the current activity to be notified periodically based on the specified criteria." Two of the parameters are:

minTime: the minimum time interval for notifications, in milliseconds. This field is only used as a hint to conserve power, and actual time between location updates may be greater or lesser than this value. minDistance: the minimum distance interval for notifications, in meters

see the documentation for [LocationManager][1]

And whenever you use it, don't forget to remove the updates whenever you don't need it anymor i.e. in onPause()

I hope that helps

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top