Technology Updates in English And Hindi भाषा !!!

Saturday, January 11, 2020

Android activity lifecycle

Android activity lifecycle


                                               fig. Activity Lifecycle


On activity creation, the activity enters the Created state. In the onCreate() method, you perform basic application startup logic that should happen only once for the entire life of the activity.This method receives the parameter savedInstanceState, which is a Bundle object containing the activity's previously saved state. If the activity has never existed before, the value of the Bundle object is null. 

Your activity does not reside in the Created state. After the onCreate() method finishes execution, the activity enters the Started state, and the system calls the onStart() and onResume() methods

onStart() :  

The onStart() call makes the activity visible to the user.

onResume() : 

When the activity enters the Resumed state, it comes to the foreground, and then the system invokes the onResume() callback.This is the state in which the app interacts with the user.

 When an interruptive event occurs, the activity enters the Paused state, and the system invokes the onPause() callback. If the activity returns to the Resumed state from the Paused state, the system once again calls onResume() method. For this reason, you should implement onResume() to initialize components that you release during onPause(), and perform any other initializations that must occur each time the activity enters the Resumed state. 

onPause() :

 It indicates that the activity is no longer in the foreground. You can also use the onPause() method to release system resources.

onStop() :  

In the onStop() method, the app should release or adjust resources that are not needed while the app is not visible to the user.


 onDestroy() is called before the activity is destroyed.The onDestroy() callback should release all resources that have not yet been released by earlier callbacks such as onStop().  


  Reference URL:



No comments:

Post a Comment