Android:如何保持 GPS 活动,直到提供更准确的位置?
我正在使用位置管理器的 requestLocationUpdates() 方法定期接收广播接收器的意图。系统正确地将意图发射到我的接收器,并且我已经能够正确使用它。唯一的问题是 GPS 位置提供程序在初始位置获取后仅保持活动状态几秒钟,而我需要它保持更长的时间,以便位置估计更加准确。
我的问题是如何使 GPS 位置提供程序对来自 LocationManager 请求位置更新。有谁知道该怎么做?
I am using the location manager's requestLocationUpdates() method to receive an intent to my broadcast receiver periodically. The system is correctly firing the intent to my receiver, and I have been able to use it correctly. The only problem is that the GPS location provider only stays active for a few seconds after the initial location acquisition, and I need it to stay on a little longer so that the location estimates are more accurate.
My question is how to make the GPS location provider stay active for each periodic request that comes from the LocationManager requestLocationUpdates. Does anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试这样的事情。我认为这是正确的做法
Try something like this. I think it is the right approach
如果您保持 LocationListener 处于活动状态,那么如果修复精度变窄,它应该会继续接收 onLocationChanged() 的更新。事实上,location.getAccuracy() 会告诉你当前的精度,
也许将 minTime 和 minDistance 都设置为 0 以便以更高的频率接收更新?将使用更多电池,但更精确。
if you keep your LocationListener active, it should continue to receive updates to onLocationChanged() if the fix accuracy narrows. and indeed location.getAccuracy() will tell you the current accuracy
maybe set minTime and minDistance both to 0 to receive updates with greater frequency? will use more battery, but is more preise.
有一个关于超时获取 GPS 位置的示例。
http://sikazi.blogspot.com/2010/09/ android-gps-timeout.html#more
There is a example about get GPS location with timeout.
http://sikazi.blogspot.com/2010/09/android-gps-timeout.html#more
要定期获取 GPS 位置,请从 locationListener 的 onLocationChanged 方法获取位置,并在 onResume 方法中指定以
毫秒为单位的时间
用于获取定期更新To get GPS location periodically, get the location from onLocationChanged method of locationListener and in onResume method specify the timing in
milliseconds
for getting periodic updates