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?
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.
When Android decides to kill our app, our activities will call onDestroy method.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With