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

Posted by  Mayank Tripathi
 1246  View(s)
Ratings:
Rate this:
  1. 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().

Answer