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 开发者_C百科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?There is a difference between the two.
- In Eclipse, "kill" kills the JVM thread, everything is destroyed.
- When the Android OS (or DDMS) decides to kill an application, the
killProcess(int)
method is called on this application, via theActivityManager
(I think). Notifications are kept. In most situations, you don't need to do cleanup. But you might have to overrideonDestroy()
.
FYI, I have come across claims (How to simulate Android killing my process) that DDMS does not kill a process the same way it is killed by the Activity LifeCycle.
精彩评论