开发者

Processes killed by the Android system: does the on going notifications are removed too?

开发者 https://www.devze.com 2023-03-20 08:32 出处:网络
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 i

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 the ActivityManager (I think). Notifications are kept. In most situations, you don't need to do cleanup. But you might have to override onDestroy().


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消