How to obtain the speed that the user of an Android device is moving? Is Location.getSpeed reliable?(如何获取Android设备用户移动的速度?Location.getSpeed 可靠吗?)
问题描述
我正在尝试从他们的 Android 设备获取用户的速度,但哪种方法最可靠?
I am trying to get the user's speed from their Android device, but which is the most reliable way to do it?
有使用GPS的location.getSpeed()
函数;这是获得速度的可靠方法吗?我是否应该使用获得的 GPS 坐标手动计算速度?还是我缺少其他方法来完成此操作?
There is the location.getSpeed()
function that uses GPS; is this a reliable way to obtain the speed? Should I instead calculate speed manually using GPS coordinates obtained? Or is there another way that I'm missing to accomplish this?
推荐答案
似乎getSpeed()方法并不总是可靠的,尤其是在低速和gps覆盖不是最佳的情况下.你可以看看 这个问题和这个 这两个都是关于 getSpeed() 的替代方案.android 开发者页面 但是说你会得到更好的性能使用 Google Location API.
It seems that the getSpeed() method is not always reliable, especially at low speed and when gps coverage is not optimal. You can have a look at this question and this one which are both about alternatives for getSpeed(). The android developper page however says that you'll get better performance by using the Google Location API.
因此,选择似乎取决于您的应用程序的使用情况:如果您的目标是在 GPS 覆盖范围较差的区域(在树林中行走)进行缓慢位移,请使用您自己的实现.在 GPS 覆盖范围广的区域内快速运行,请使用 Google Location API.
So it appears that the choice is depending on the usage of your app: if you target slow displacement in area with poor gps coverage (walking in the wood), use your own implementation. Fast in area with good GPS coverage, use the Google Location API.
这篇关于如何获取Android设备用户移动的速度?Location.getSpeed 可靠吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何获取Android设备用户移动的速度?Location.getSpeed 可靠吗?


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01