Geo Fix command does not pass altitude

你。 提交于 2019-12-08 19:16:35

问题


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

回答1:


This is a bug in the emulator and has been reported at https://code.google.com/p/android/issues/detail?id=24809



来源:https://stackoverflow.com/questions/3292788/geo-fix-command-does-not-pass-altitude

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!