This behavior is triggered by applications (ab)using Service.startForeground()
.
The idea behind using startForeground()
is that you provide a notification through which users can interact with your app while it is running. For instance, if it's a music player, make sure you're providing the persistent notification as a parameter of the function, so that Android knows the user already has a way of letting your app invoke stopForeground()
.
You can basically see this as "public shaming", because apps should behave nicely on the platform and let the system kill them if it needs to.
(In my case, the culprit was actually Robospice; here's the line in question and the associated issue.)