通过adb使用geo fix命令时,我似乎无法获得卫星计数.
地理修复帮助读取:
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)
Run Code Online (Sandbox Code Playgroud)
我使用以下命令设置地理位置以触发OnLocationChanged执行:
geo fix -106.1221 52.1311 514 5
Run Code Online (Sandbox Code Playgroud)
在OnlocationChanged中:
Location newestloc = loc;
Bundle sats = newestloc.getExtras();
int satcount = 0;
satcount = sats.getInt("satellites");
Run Code Online (Sandbox Code Playgroud)
但是每当我打电话给satcount时,我总是得到0.是否通过geo fix传递的卫星数量不计算在内?
有没有其他方法可以获得手机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++;
}
}
Run Code Online (Sandbox Code Playgroud)
每次我得到修复时,这应该至少返回1,但它永远不会从0变化.
http://developer.android.com/reference/android/location/GpsStatus.html
尝试 getSatellites()
您使用什么类型的手机进行测试?您是否尝试过检查 lbstest 模式返回的内容?可能是手机本身没有接收到任何卫星。
| 归档时间: |
|
| 查看次数: |
6596 次 |
| 最近记录: |