LocationManager does not stop PendingIntent requests when the application is disconnected

I have been working on Android locations for a long time, but recently I decided to focus more on PendingIntents to handle updates. From the documents, I tried to understand cases related to edges, mainly what will happen to my requests if my application is terminated either by the system or by a force closed by the user. Unfortunately, the documents are not very detailed about this, so I created a test application.

To my surprise, if I request location updates using PendingIntent and then terminate the application, my request is not canceled . This means that if I start a GPS request, and then decide to drop my application from the "recents" list, the GPS will continue to try to get the lock permanently (or until the device reboots), although my application is no longer running. I even tried Force Stopping an application that did not help, and then manually stopped the process, which was still on the list of cached processes, but to my dismay I could not even stop the request!

I know that my application process can be restarted by the system when an update becomes available because my receivers are registered at the manifest level, but I am surprised that I expect the location manager to complete my request, given that as far as I can tell, I cannot clean up after my application in these situations .

I mean:

  • Imagine that I just started a background single GPS request (I'm working on a background lib, so we are not tied to any activity or to the context of the user interface), expecting it to close it after 30 seconds if it is not available.
  • The user decides to remove my application or force stop it at this time.
  • , , GPS . , onDestroy ( ).

- , , , , . , GPS -, . , , , ... , , , GPS ?

- / ?

Nexus 5 w/4.4.2

:

, Android (Galaxy Nexus 4.3) . PendingIntent, , .

+3

All Articles