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

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
 695  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!