location.getSpeed()适用于三星Galaxy Nexus,但不适用于Galaxy S.

时间:2012-05-07 11:27:35

标签: android performance navigation gps location

我想在我的应用中显示当前的速度。在Galaxy Nexus上它工作正常,但Galaxy S只显示0.0我使用以下代码来获得速度。

location.getSpeed()

从我所知道的文件中:

  

public float getSpeed()   自:API级别1   以米/秒为单位返回设备对地速度。如果hasSpeed()为false,则返回0.0f>。

可能是Galaxy S上的hasSpeed是假的吗? BUt函数应该从API级别1开始工作,所以我不明白问题出在哪里。

任何人都可以帮忙吗?

thx

编辑:

if(location.hasSpeed())
{
    speed = (location.getSpeed()*3.6);
}
else
{
    if(lastLoc!=null)
        {
            double time=(System.currentTimeMillis()-lastUpdate)*1000;
            speed=(location.distanceTo(lastLoc)/time)*3.6;
        }
}

1 个答案:

答案 0 :(得分:0)

好吧看起来gps在我的银河系中有些错误。尝试了市场的其他gps车速表,它也无法显示出任何速度。

我还发现三星Galaxy S上的GPS真的很糟糕。好吧,我将不得不忍受它=)

相关问题