home
/
developersection
/
interviews
/
the last callback in the lifecycle of an activity is ondestroy(). the system calls this method on your activity as the final signal that your activity instance is being completely removed from the sys
The last callback in the lifecycle of an activity is onDestroy(). The system calls this method on your activity as the final signal that your activity instance is being completely removed from the sys
onPause() and onStop() will not be invoked if finish() is called from within the onCreate() method. This might occur, for example, if you detect an error during onCreate() and call finish() as a result. In such a case, though, any cleanup you expected to be done in onPause() and onStop() will not be executed.
Best practice in Android development is to have the activity perform most cleanup during onPause() and onStop(). However, if the activity includes background threads that are created during onCreate(), or other long-running resources that could potentially leak memory if not properly closed, you should kill them during onDestroy().
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Can you answer this question?
Write Answer1 Answers