1

假設我有一個app並且在其活動中,我將註冊pendingIntentLocationManager每10分鐘觸發一次。LocationManager註冊的持久性是什麼

就像這個例子: Android: How to get location information from intent bundle extras when using LocationManager.requestLocationUpdates()

如果用戶關閉了appLocationManager仍然保持射擊pendingIntent

這樣我就可以在我的應用程序未運行時從我的應用程序的BroadcastReciver(清單版本)調用此pendingIntent的通知。

如果是,那麼當LocationManager被實際清理後,電話重啓後?

回答

0

如果您希望在應用程序退出後進行可靠的位置更新,請考慮使用AlarmManagerexample)每隔10分鐘喚醒設備。每次報警觸發時,註冊並取消註冊您的位置監聽器,以便GPS可以處於空閒狀態。

您可能還想使用類似WakefulIntentService(請參閱here)的內容,以便設備在您的應用等待位置更新時保持喚醒狀態。 Android會中斷您的BroadcastReceiveronReceive()方法,如果時間太長而且沒有持有WakeLock