2011-03-04 23 views
6

雖然使用地理修復命令,但通過adb我似乎無法獲得衛星數。不能得到衛星數Android

的地理修復幫助寫着:

geo fix <longitude> <latitude> [<altitude> [<satellites>]] 
allows you to send a simple GPS fix to the emulated system 
The parameters are: 

<longitude> longitude, in decimal degrees 
<latitude> latitude, in decimal degrees 
<altitude> optional altitude in meters 
<satellites> number of satellites being tracked (1-12) 

我用下面的命令來設置地理位置來觸發OnLocationChanged執行:

geo fix -106.1221 52.1311 514 5 

在OnlocationChanged:

Location newestloc = loc; 
Bundle sats = newestloc.getExtras(); 
int satcount = 0; 
satcount = sats.getInt("satellites"); 

然而每當我打電話給satcount時,我總是得到0.是衛星的數量是pa通過未計算的地理修復?

有沒有其他的方法來獲取手機的GPS當前所看到的號碼衛星?

編輯: 我也曾嘗試下面的代碼,以及:

GpsStatus gpsstat = mlocManager.getGpsStatus(null); 
Iterable sats = gpsstat.getSatellites(); 
Iterator satI = sats.iterator(); 
     int count = 0; 
     while(satI.hasNext()){ 
      GpsSatellite gpssatellite = (GpsSatellite) satI.next(); 
      if (gpssatellite.usedInFix()){ 
      count++; 
      } 
     } 

這項工作應在最低限度返回1,每次我得到一個固定的時間,但它從來沒有從0

回答

-1

關閉的問題,因爲我一直沒能找到信息和應用程序似乎沒有衛星數量的功能罰款,因爲這僅僅是一個額外的領域,我們正在看。

1

http://developer.android.com/reference/android/location/GpsStatus.html

改變

嘗試getSatellites()

您正在測試什麼類型的手機? 您是否嘗試過檢查lbstest模式返回的內容?可能是因爲手機本身沒有拿起任何衛星。

+0

我也試過。 (Iterator sats =(Iterator )mlocManager.getGpsStatus(null).getSatellites();''sats.hasNext();){' 'count ++ ;'' sats.next();'' }'' = satcount計數;' 以上不工作,要麼,還是返回0 – Sorean 2011-03-04 18:45:32

+1

我用三星Galaxy S.測試,但,這是一個側請注意,正如我所提到的,我正試圖用adb完成計數。我的意思是它也會轉移到手機上,但如果應用程序在adb中提取它,它應該轉移到手機上。該應用程序的工作原理是,它獲取GPS定位並將其顯示在屏幕上(測試過),但不顯示它檢測到的衛星數量。 – Sorean 2011-03-07 16:20:01

+0

你可以檢查adb日誌嗎? – 2011-03-08 17:32:39

1

在某些版本中,Android處理地理修復命令似乎存在一個錯誤。您可能想嘗試geo fix -106.1221 52.1311 514 5 12,其中在某些實施中數字5被忽略,並且將12作爲衛星的數量。 因此,對有缺陷的系統的實際語法將

geo fix <longitude> <latitude> [<altitude> [<dummy> <satellites>]] 
+0

我也試過這個,它不起作用。 – Sorean 2011-04-06 18:05:32