Immer der Zusammenhang in einem Thread genannt, die von einem Dienst

Habe ich das folgende Stück code:

public class DumpLocationLog extends Thread {
    LocationManager lm;
    LocationHelper loc;
    public void onCreate() {
        loc = new LocationHelper();
        lm = (LocationManager) Context.getSystemService(Context.LOCATION_SERVICE);
    }
    public void run() {
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, loc);
    }
}

Ich soll es ausgeführt werden, von einem remote-service, aber in der Zeile lm = (LocationManager) Context.getSystemService(Context.LOCATION_SERVICE); ich eine NullPointerException Fehler natürlich, weil der context null ist.

Wie bekomme ich den Zusammenhang hier? getBaseContext() oder getApplicationContext() funktioniert nicht.

InformationsquelleAutor noloman | 2011-08-06

Schreibe einen Kommentar