地理修复命令不通过高度 [英] Geo Fix command does not pass altitude
问题描述
在Android 2.2的模拟器,将地理修复命令似乎没有正常工作。仿真器响应OK,而 onLocationChanged()
正确调用我的程序。但是,位置
对象似乎不完整 - 它注册的纬度和经度得很好,但它不包含高空阅读: hasAltitude()
收益假
。
任何想法,为什么?
例仿真命令:
地理修复-74 40.75 500
地理修复-77 39 400.0
code片断:
公共无效onLocationChanged(位置LOC){
的System.out.println(onLocationChanged称为);
如果(loc.hasAltitude()){
双newalt = loc.getAltitude();
的System.out.println(新的高度:+ newalt);
GPS [海拔] = newalt;
}其他{
的System.out.println(无海拔高度修正);
}
GPS [龙] = loc.getLongitude();
的System.out.println(GPS [LONG]);
GPS [LAT] = loc.getLatitude();
的System.out.println(GPS [LAT]);
}
示例输出:
onLocationChanged调用
无海拔高度修正
-74.012333333333333333
40.756666666666666667
onLocationChanged调用
无海拔高度修正
-77.012833333333333335
39.006499999999999996
这是在模拟器中的错误,并已在的 HTTPS://$c$c.google.com/p/android/issues/detail ID = 24809
On Android 2.2 Emulator, the "geo fix" command seems not to be working properly. The emulator responds "OK", and onLocationChanged()
is properly called in my program. However, the Location
object seems not to be complete - it registers latitude and longitude just fine, but it does not contain an altitude reading: hasAltitude()
returns false
.
Any ideas why?
Example emulator commands:
geo fix -74 40.75 500
geo fix -77 39 400.0
Code snippet:
public void onLocationChanged(Location loc) {
System.out.println("onLocationChanged Called");
if (loc.hasAltitude()) {
double newalt = loc.getAltitude();
System.out.println("new altitude: " + newalt);
gps[ALTITUDE] = newalt;
} else {
System.out.println("No altitude fix");
}
gps[LONG] = loc.getLongitude();
System.out.println(gps[LONG]);
gps[LAT] = loc.getLatitude();
System.out.println(gps[LAT]);
}
Sample Output:
onLocationChanged Called
No altitude fix
-74.012333333333333333
40.756666666666666667
onLocationChanged Called
No altitude fix
-77.012833333333333335
39.006499999999999996
This is a bug in the emulator and has been reported at https://code.google.com/p/android/issues/detail?id=24809
这篇关于地理修复命令不通过高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!