I create a new thread in an activity and I rely on onPause() to interrupt the thread. If my app crashes, or the Activity somehow ceases to exist, I want the thread to be kil
Yes , onPause()
will be called when an activity is no longer running. Suppose an activity is closed then the sequence of events will be onPause()
-> onStop()
-> onDestroy()
. Even if your activity slips into the background when another activity starts or when the screen switches off, onPause()
is always called even if the other two methods aren't called. So even if activity ceases, onPause()
will be called and your thread will be killed.
But when your app crashes, along with your entire activity, even the thread that you have started will be taken care of by Android by finishing it all.