当更新间隔设置为 10 秒时,管理器位置将在多长时间内监听 GPS 提供商而没有得到答案
当位置管理器正在监听 GPS 提供商,两次通知之间的间隔时间为 10 秒(这意味着 requestLocationUpdate 的第二个参数为 10000)并且 GPS 没有任何信号时,管理器会监听多长时间才会停止?或者它会听 GPS 提供商的声音,直到他获得第一个位置?
这非常重要,因为我正在努力节省尽可能多的电池,如果经理正在听,直到他获得第一个位置,我想在短时间内阻止他。
when a location manager is listening to a GPS provider with interval time of 10 secondes between notifications (it means that the second parameter of requestLocationUpdate is 10000) and the GPS doesn't have any signal, how long will the manager listen before stoping? or will it listen to the GPS provider until he gets the first location ?
it's very important because i'm trying to save as much battery as i can, and if the manager is listening until he gets the first location i would like to stop him after a short time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您开始请求位置更新时,一旦找到位置,就会触发位置侦听器。然后时间间隔因素出现在图片中,在您的情况下为 10 秒,之后它将再次接收位置。
因此,一旦找到位置,您就可以删除位置更新。
when you start request location updates, the location listener will be triggered as soon as the location is found. And then the time interval factor comes in to picture which is 10 secs in your case, after which it will receive location again.
so you can remove the location updates once the location has been found.
不确定这对您的情况是否有帮助,但如果确实不需要节省电池寿命,我通常会停止事件侦听器。您可以根据您的应用轻松重启它。
像这样的事情:
Not sure if this helps in your case but I usually stop the event listener if it is not really needed to conserve battery life. You can easily restart it based on your app.
Some thing like: