我有這樣的:。獲取地點每秒
public class GpsUpdate extends Observable implements LocationListener {
private int x_position;
private int y_position;
private float currentAccuracy;
public GpsUpdate(Observer observer){
addObserver(observer);
}
@Override
public void onLocationChanged(Location location) {
int lat = (int) (location.getLatitude() * 1E6);
int lng = (int) (location.getLongitude() * 1E6);
setAccuracy(location.getAccuracy());
setX_position(lat);
setY_position(lng);
setChanged();
notifyObservers();
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
public int getX_position() {
return x_position;
}
public void setX_position(int x_position) {
this.x_position = x_position;
}
public int getY_position() {
return y_position;
}
public void setY_position(int y_position) {
this.y_position = y_position;
}
public void setAccuracy(float currentAccuracy) {
this.currentAccuracy = currentAccuracy;
}
public float getAccuracy(){
return currentAccuracy;
}
}
這種方法(onLocationChanged())通知其他類的另一種方法(update()方法),其位置被改變,但我需要即使電流與以前相同,也要收集所有座標。
_GPSUPDATE = new GpsUpdate(this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, _GPSUPDATE);
@Override
public void update(Observable observable, Object data) {
xCurrent = _GPSUPDATE.getX_position();
yCurrent = _GPSUPDATE.getY_position();
.....
}
那麼,我有什麼要添加/更改每秒得到位置?
所以最新的問題? –
爲什麼你想快速殺死用戶的電池? –
無論如何;]它可以每隔10秒,但我需要獲得座標,即使它們沒有改變。 – aptyp