Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 923
Guillaume Brunerie Avatar asked Jul 14 '11 01:07

Guillaume Brunerie


People also ask

What happens when Android decides to shut down a process?

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.

How do I know if my app is destroyed Android?

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.

Which method is called when app is killed Android?

When Android decides to kill our app, our activities will call onDestroy method.


1 Answers

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().
like image 97
rds Avatar answered Oct 19 '22 00:10

rds