When the application starts, if it is not already running, it receives a new process identifier. This identifier stays with it until it is no longer in memory. (This can be achieved and verified using the "Force Stop" option in the application settings.)
However, when the user clicks the Back or Home buttons, the application does not exit and in most cases stops or stops.
You can read this documentation , which details the process life cycle. Points 1 and 2 basically say that the foreground process (or one after something superficial, such as dialogue) will not be stopped if it is not absolutely necessary (power is close or there is no memory). Point 3 is important; he says that any process that is no longer needed, i.e. the user "closed" it - it may or may not be killed, depending on the deviceβs memory. And finally, paragraph 4, everything that does nothing, but just .. existing .. will be killed as soon as possible.
You can also watch the Activity life cycle . This will show you exactly when each of the application steps will be executed (that is, when it is paused, when it will stop and when it will be destroyed). The only thing it does not apply to is the reallocation of memory (or orientation changes that repeat the entire life cycle).
In conclusion, remember that Android is smart. He manages his processes better than most developers, and tries to save as many processes as possible for easy reuse. Unless you are absolutely sure that you want your process to be out of memory, you should never kill it. And the way we must kill and control processes is never good .
Eric source share