In Android 2.2 Emulator, the "geo fix" command does not seem to work correctly. The emulator answers "OK", and onLocationChanged() correctly called in my program. However, the Location object seems incomplete: it registers latitude and longitude just fine, but does not contain a height value: hasAltitude() returns false .
Any ideas why?
Examples of 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]); }
Output Example:
onLocationChanged Called No altitude fix -74.012333333333333333 40.756666666666666667 onLocationChanged Called No altitude fix -77.012833333333333335 39.006499999999999996
android android-emulator android-2.2-froyo
Sirboss
source share