我需要每分鐘獲取GPS位置更新(電池壽命不是問題,因爲設備將在車內充電)。這是一個公司交付應用程序,與車輛跟蹤,與谷歌地圖結合使用,以跟蹤送貨計劃人員的旅程等。一致的GPS更新 - AlarmManager或requestLocationUpdates()?
我已經使用AlarmManager和LocationManager.requestLocationUpdates()與監聽器。後者看起來有些rope and,依靠文檔,它可能會或可能不會提供位置。但我已經看到,儘管minTime設置爲1分鐘,距離爲0/1,但我仍然只看到每5分鐘更新一次或兩次。
private void startGeoLocationSender()
{
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new GeoLocationListener(this);
// MINIMUM TIME TO REQUEST , MIN DISTANCE TO REQUEST, LISTENER
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
AppSettings.COLLECTOR_PROC_1_MINS,
AppSettings.COLLECTOR_DISTANCE_1_M, locationListener);
}
那麼,是不是值得我只是要回到一個AlarmManager和手動強制更新它是可靠的?還是有另一種方法,在特定的更新時間內100%可靠?什麼更適合我的要求?
PS。我非常瞭解這個主題的其他幾千個主題,但我從來沒有見過這樣一個好的Vs Evil趨勢。一些民衆發誓由位置聽衆,和其他人只AlarmManagers。