Android设备的移动速度 [英] Android Device Movement Speed
本文介绍了Android设备的移动速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要计算在每个位置更新的移动速度。
I need to calculate the movement speed on every location update.
我用下面的code的位置更新。
I'm using the following code for the location update.
public class FlirtLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location location)
{
// My Code on the location update
}
@Override
public void onProviderDisabled(String provider)
{
Log.i("OnProviderDisabled", "OnProviderDisabled");
}
@Override
public void onProviderEnabled(String provider)
{
Log.i("onProviderEnabled", "onProviderEnabled");
}
@Override
public void onStatusChanged(String provider, int status,
Bundle extras)
{
Log.i("onStatusChanged", "onStatusChanged");
}
}
如何获得移动速度?我应计算的第一和下一个位置之间的两个更新和距离之间的时间?或者是有一些其他的方式?
How to get the movement speed? Should I calculate the time between the two updates and the distance between first and next location? Or is there some other way?
推荐答案
由于@jsmith表示,目前在位置在
。 getSpeed()
方法的.class
As @jsmith said there is a getSpeed()
method in the Location.class
.
public class LocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location location)
{
float speed = location.getSpeed();
}
}
这篇关于Android设备的移动速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文