在android中计算用户移动速度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11643727/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Calculating user moving speed in android
提问by koti
I need to calculate Speed with which the user is moving. So we need two things to calculate speed which are GPS
and Accelerometer
.
我需要计算用户移动的速度。所以我们需要两件事来计算速度,分别是GPS
和Accelerometer
。
But both have their limitations.
但两者都有其局限性。
1)GPS
is not available all the time.While I getting the current location of user always I am getting from Network provider
only and not from GPS
.
1)GPS
不是一直可用。虽然我总是获取用户的当前位置,但我Network provider
只能从GPS
.
2)Accelerometer
is not accurate.
2)Accelerometer
不准确。
So which approach should I go with?
那么我应该采用哪种方法?
采纳答案by Shishir Shetty
An implementation, based on the GPS, is available at this link
可在此链接中获得基于 GPS 的实现
回答by Ali
The most accurate results can be obtained by using both of them, through sensor fusion.See my previous answer to question Using accelerometer to calculate speedsor to another question GPS V.S. accelerometer to calculate distance.
两者结合使用,通过传感器融合,可以获得最准确的结果。请参阅我之前对使用加速度计计算速度或另一个问题GPS VS 加速度计计算距离的回答。
As for the accuracy of the accelerometer, see Get velocity from 3DVector using accelerometer sensor.
至于加速度计的精度,请参阅使用加速度计传感器从 3DVector 获取速度。
If you want to track the user indoor, see what you can actually do at question Android accelerometer accuracy (Inertial navigation).
如果您想在室内跟踪用户,请查看您实际上可以在Android 加速度计精度(惯性导航)问题上做些什么。
回答by Buneme Kyakilika
You can call .getSpeed() on the locationprovider
您可以在 locationprovider 上调用 .getSpeed()