1

Lets say I have an app and within its activity I will register pendingIntent with LocationManager to be triggered every 10mins.

like in this example : Android: How to get location information from intent bundle extras when using LocationManager.requestLocationUpdates()

If user closes the app will the LocationManager still keep firing pendingIntent ?

so that I can invoke notification from BroadcastReciver (manifest ver) of my app for this pendingIntent when my app is not running.

If yes, then when the LocationManager is actually cleaned, after phone restart?

Community
  • 1
  • 1
AndroidGecko
  • 14,034
  • 3
  • 35
  • 49

1 Answers1

0

If you want reliable location updates after the app exits, please consider using AlarmManager (example) to wake up the device every 10 minutes. Register and unregister your location listener each time the alarm fires so that the GPS can be otherwise idle.

You may also want to use something like WakefulIntentService (see here) so that the device will stay awake while your app is waiting for a location update. Android will interrupt your BroadcastReceiver's onReceive() method if it takes too long and isn't holding a WakeLock.

Community
  • 1
  • 1
acj
  • 4,821
  • 4
  • 34
  • 49