在我的應用程序中,我設置了一個位置管理器來每10分鐘更新當前位置(或者我認爲)。相反,我得到每5分鐘更新:爲什麼我的應用程序位置更新速度比我指定的快兩倍?
10-03 23:45:17.153: DEBUG/TheApp(2025): Location updated with accuracy: 48.0m
10-03 23:50:23.162: DEBUG/TheApp(2025): Location updated with accuracy: 48.0m
10-03 23:55:23.074: DEBUG/TheApp(2025): Location updated with accuracy: 48.0m
10-04 00:00:23.077: DEBUG/TheApp(2025): Location updated with accuracy: 48.0m
下面的代碼:
LocationManager locationManager = (LocationManager)
this.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
Log.d(APP_TAG, "Location updated with accuracy: " + location.getAccuracy() + "m");
}
//Other methods are empty and omitted for brevity
};
int TEN_MINUTES = 10 /*Minutes*/ * 60 /*sec per min*/ * 1000 /*ms per sec*/;
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
TEN_MINUTES, 0, locationListener);
誰能解釋這是爲什麼不工作,我想?例如。爲什麼每5分鐘更新一次而不是10次?
android可以是一個神祕的情人.. – Ian
有趣的是,如果另一個應用程序正在做位置更新,那麼我的偵聽器被解僱?假設這種說法有道理。 –