使用 COARSE 的 android 速度
大家好 我怎样才能在android中使用ACCESS_COARSE_LOCATION
获得速度
谢谢
hi to all
how can i get the speed using the ACCESS_COARSE_LOCATION
in android
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您好,您指的是
Location.getSpeed()
我相信这是一个可选字段,可能取决于设备是否真正支持它。首先尝试一下,幸运的是,数学和科学会帮助我们:) 只需计算从
LocationProviders
获取更新时的速度即可。确保计算经纬度随时间变化的距离,作为两个位置更新记录的时间戳的差异。它不一定非常准确(可能真的很吵),但制作柠檬水比吃腐烂的水果更好……希望这会有所帮助。确保也只比较同一提供商的增量。您可能会发现自己正在调整手动计算,因为设备提供商非常多样化,并且不能保证时间总是向前推进。
Hi are you referring to
Location.getSpeed()
I believe that is an optional field and probably up to the device to actually support it. First off try thisLuckily Math and Science will help us :) Just calculate the speed as you get updates from your
LocationProviders
. Make sure to calculate the distance between the lat,longs over times as the difference of the recorded times stamps of two Location updates.It won't necessarily be greatly accurate (probably really noisy) but it's better to make lemonade than to have rotted fruit ... hopefully this helps. Make sure to only compare deltas across the same provider too. You will probably find yourself tweaking the manual calculation because the devices providers are very diverse and don't guarantee that time always moves forward.
最有可能的是,你不能。 “粗略”的定位技术只能知道你在几百米范围内的位置。您的速度可能会有很大差异。如果您需要知道您的速度,您很可能需要一个“精细”的位置提供商。
或者,更好的是,使用 Criteria 对象来规定您需要了解设备的速度,并让它引导您找到最佳的提供商来使用。
Most likely, you cannot. Location technology that is "coarse" only knows where you are within several hundred meters. Your speed could vary wildly. If you need to know your speed, you will most likely need a "fine" location provider.
Or, better yet, use the Criteria object to stipulate that you need to know the device's speed, and let it guide you to the best provider to use.