Android 多久请求一次位置更新?
Android 多久请求一次位置更新?例如,如果您向位置管理器添加接近警报,它会多久更新一次位置?
文档中写道:“如果屏幕进入睡眠状态,则每 4 分钟检查一次接近警报。这样可以确保设备不会永远处于唤醒状态,从而节省电池寿命”
但是如果屏幕不进入睡眠状态怎么办?睡觉?
预先感谢
迈克
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
LocationManager
类中,有一个名为requestLocationUpdates
的方法,可以使用不同的参数集进行调用。它“注册当前活动,根据指定的标准定期通知。”其中两个参数是:
minTime:通知的最小时间间隔,以毫秒为单位。该字段仅用作节省电量的提示,位置更新之间的实际时间可能大于或小于该值。
minDistance:通知的最小距离间隔,以米为单位,
请参阅
[LocationManager][1]
的文档并且每当您使用它时,不要忘记在不再需要时删除更新即在
onPause()
我希望有帮助
In the
LocationManager
class, there is a method calledrequestLocationUpdates
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