![](/img/trans.png)
[英]GCM is not working on Nexus 7 it is on Samsung Galaxy S3
[英]location.getSpeed() works on Samsung Galaxy Nexus but not on Galaxy S
我想在我的應用程序中顯示當前速度。 在Galaxy Nexus上可以正常工作,但Galaxy S僅顯示0.0,我使用以下代碼來獲取速度。
location.getSpeed()
從文檔中我知道:
public float getSpeed()從以下版本開始:API級別1以米/秒為單位返回設備在地面上的速度。 如果hasSpeed()為false,則返回0.0f。
在Galaxy S上hasSpeed是否為假? 從API級別1開始,該功能應該可以正常工作,所以我不知道問題可能在哪里。
有人可以幫忙嗎?
謝謝
編輯:
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;
}
}
好的,看來gps在我的銀河系上有問題。 嘗試了市場上的另一款GPS速度計,它也無法顯示任何速度。
我還發現,三星Galaxy S上的GPS確實很糟糕。 很好,我將不得不忍受=)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.