Reputation: 1519
In my Android app I have a couple of foreground services running (started with START_STICKY
, but changing that does not seem to make any difference). When the user quits the app by swiping it away in the task manager I use the onTaskRemoved
callback to do some cleanup/syncing in the services and then stop them using stopSelf()
. I can verify that all services are stopped in the developer settings.
My problem now is that I would expect the app process to be killed too so any remaining singletons, etc. would get cleaned up and the next time the user launches the app it is in a "clean" state. I can verify that this happens if I don't start any services at all and swipe away the app in the task manager. But as soon as my services come into play the app process does not seem to get killed, even after stopping ALL services.
I am using a Samsung Galaxy Active Tab 3 with Android 12 to test this.
Upvotes: 1
Views: 131
Reputation: 95578
Android determines when, and if, the hosting OS process gets killed. You have no control over when, or even if, this happens. Different manufacturers have different strategies (some are very agressive and kill off processes immediately, some don't).
Upvotes: 1