2010-07-20 10 views
7

Auf dem Android 2.2-Emulator scheint der Befehl "geo fix" nicht ordnungsgemäß zu funktionieren. Der Emulator antwortet mit "OK" und onLocationChanged() wird ordnungsgemäß in meinem Programm aufgerufen. Das Location Objekt scheint jedoch nicht vollständig zu sein - es registriert Längen- und Breitengrad gut, aber es enthält keinen Höhenmesswert: hasAltitude() gibt false zurück.Befehl "Geo Fix" überschreitet die Höhe nicht

Irgendwelche Ideen warum?

Beispiel Emulator Befehle:

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]); 
} 

Beispielausgabe:

onLocationChanged Called 
No altitude fix 
-74.
40.756666666666666667 
onLocationChanged Called 
No altitude fix 
-77.012833333333333335 
39.006499999999999996 
+0

Ähnlich Frage? http://stackoverflow.com/questions/11054379/why-does-location-getaltitude-always-return-zero-at-least-in-the-emulator – roarster

Antwort