My application is using an on going notification. I noticed that when I kill my application via DDMS, the on going notification isn’t cancelled. However, when I’m doing Eclipse → Run, the process is killed and the notification is canceled.
What happens when the Android system decides to kill my application? Is the notification canceled or do Android just kill the process without doing any cleanup?
Edit:
And if there is some cleanup done, how can I simulate this behaviour in order to test if my application is behaving correctly?
Android might decide to shut down a process at some point, when resources are required by other processes that are more immediately serving the user. Application components running in the process that's killed are consequently destroyed.
there's no way to determine when a process is killed. From How to detect if android app is force stopped or uninstalled? When a user or the system force stops your application, the entire process is simply killed. There is no callback made to inform you that this has happened.
When Android decides to kill our app, our activities will call onDestroy method.
There is a difference between the two.
killProcess(int)
method is called on this application, via the ActivityManager
(I think).
Notifications are kept.
In most situations, you don't need to do cleanup. But you might have to override onDestroy()
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With