我有以下课程
public class GPSManager {
Context MyContext;
boolean GotLocation = false;
Location CurrentLocation;
public GPSManager(Context context){
MyContext = context;
}
LocationManager locationManager = (LocationManager)MyContext.getSystemService(MyContext.LOCATION_SERVICE);
LocationListener locationlistener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
GotLocation = true;
CurrentLocation = location;
}
//ETC
从活动中调用如下调用
GPSManager myGPS = new GPSManager(this);
但是当我运行它失败时,我相信它与上下文传递有关,因为在调试器中我认为(对于 Eclipse 来说仍然是新的)它是一个空值。
我想要的只是一个返回当前位置的类(不需要最后知道的位置)