2012-04-06 4 views
2

Ich verwende Android 2.3.1 Projekt, um einen aktuellen Standort mit Hilfe von LocationManager.GPS_PROVIDER zu erhalten.Android: Warum schlägt native_start in startNavigating() auf Android 2.3.1 Emulator fehl?

Dies ist mein Code

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    LocationManager locManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE); 
    LocationListener locListener = new BTILocationListener(); 

    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener); 
} 

public class BTILocationListener implements LocationListener { 

    @Override 
    public void onLocationChanged(Location loc) { 
     Log.d("BTILocation", "Inside onLocationChanged() ---"); 

     if (loc != null) { 
      double latitude = loc.getLatitude(); 
      double longitude = loc.getLongitude(); 

      String locationstr = "Latitude = " + latitude + " longitude = " +longitude; 

      Log.d("BTILocation", locationstr); 



     } 
    } 

    @Override 
    public void onProviderDisabled(String provider) { 
     Toast.makeText(getApplicationContext(), "GPS Disabled", Toast.LENGTH_SHORT).show(); 
     Log.w("BTILocation", "GPS is Disabled"); 
    } 

    @Override 
    public void onProviderEnabled(String provider) { 
     Toast.makeText(getApplicationContext(), "GPS Enabled", Toast.LENGTH_SHORT).show(); 
     Log.w("BTILocation", "GPS is Enabled"); 
    } 

    @Override 
    public void onStatusChanged(String provider, int status, Bundle extras) { 
     // TODO Auto-generated method stub 

    } 

} 

Der Berechtigungssatz Ich benutze -

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> 

Ich benutze offene Telnet-Verbindung

telnet localhost 5544 
geo fix 12 22 

ich folgende Fehler auf logcat sehen -

E/GpsLocationProvider( 75): native_start failed in startNavigating() 

Das in onLocationChanged (loc loc) zurückgegebene location-Objekt ist unter 2.3.1 immer null.

Der gleiche Code funktioniert gut in Android 2.1 und 4.0. Bitte helfen Sie mir, dieses Problem zu lösen, ich habe Google-Suche versucht, aber ich konnte die Lösung nirgends finden. Vielen Dank! Ich habe keine Google APIs, die mit Android API Level 7 kompatibel sind, weiß jemand, wie ich es herunterladen kann?

Antwort

0

Es scheint, dass es ein bekanntes Problem mit Plattform 2.3 ist Ich habe Google APIs für Plattform 2.2 und 2.1 mit Android SDK-Manager heruntergeladen. Ich musste nur das veraltete Kontrollkästchen überprüfen, um die benötigten Pakete herunterladen zu können.

0

Ich habe den gleichen Fehler mit 4.4.2 in API-Ebene 17. Dies ist sporadisch obwohl, nicht wirklich klar, was das Problem behebt. Ich habe den Emulator neu gestartet, System alle üblichen Sachen, nichts hat geholfen.

Aber ich öffnete einen anderen Emulator und das behob sie beide.

+0

das ist wirklich komisch. – coredump

+0

Weitere Probleme - https://groups.google.com/forum/?fromgroups=#!topic/adt-dev/Z8NKJKyVmts – satyajit