Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When Android kills an app, can a function be stopped halfway?

Tags:

android

I am wondering: when an app is to be killed, does Android wait for the currently running function to return, or does Android stop it before it ends by itself?

like image 213
user2026661 Avatar asked Jan 30 '13 19:01

user2026661


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.

Which method is called when app is killed Android?

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

When can Android activity be destroyed?

Handling Configuration Changes The Activity lifecycle is especially important because whenever an activity leaves the screen, the activity can be destroyed. When an activity is destroyed, when the user returns to the activity, the activity will be re-created and the lifecycle methods will be called again.


1 Answers

The OS kills the JVM process, with all the "functions" in all the threads. In practical terms, you shouldn't assume that a method is a transaction. Instead, one should assume it can be terminated at any time and design appropriately.

like image 98
full.stack.ex Avatar answered Sep 21 '22 12:09

full.stack.ex