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 fi开发者_如何转开发x");
}
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
精彩评论