0
如何从LocationListener.onlocationchanged()更改活动字段?我想我必须使用一个处理程序,但不知道该怎么做,到底... 我的代码是这样的:Android,如何从LocationListener.onlocationchanged()更改活动字段?
public class Main extends Activity {
private Double lat, lon;
private LocationManager locationManager;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListenerGps = new CurrentLocationGps();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListenerGps);
}
}
public class CurrentLocationGps implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
lat = loc.getLatitude();
lon = loc.getLongitude();
>>>>>>>>---<<<<<<<<< How do I pass this values to Main activity fields?
}
}
}
我用它作为内部类(我在问题中编写的代码是错误的......),但不知道外部类是从内部类访问的......谢谢! ;-( – MarcoS 2011-06-07 13:46:10