为什么 location.getSpeed() 总是 return 0

Why does location.getSpeed() always return 0

我需要从 myLocation 获取我的速度,它总是 returns 0 ...我需要帮助

@Override
public void onLocationChanged(Location location) {
    Log.e("location",String.valueOf(location.getSpeed()));
}

getSpeed()方法returns速度,如果可用,

If this location does not have a speed then 0.0 is returned.

如果你确定你有适当的速度显示并且必须返回某些东西肯定然后考虑 this 代码,并尝试使你的代码与那个相同。