Explain the life-cycle of activity.

: 207
Paper : Android Development FAQ (Frequently Asked Questions and answers) | Platform : Apps Development | Category : Development FAQs

The lifecycle of activity:

  • OnCreate(): It is the first method called where activity is created. The views are created in this as well as data is collected from bundles.
  • OnStart(): This method is called when the activity becomes visible to the user. It may be called after OnResume() when the activity becomes foreground and OnStop() if it is hidden.
  • OnResume(): This callback method is called when the activity starts interacting with the user.
  • OnPause(): It is been called when the activity comes into the background but hasn't killed yet.
  • OnStop(): The callback method is called when the activity is no more noticeable to the user.
  • OnDestory(): The method is called to destroy the activity to free up the memory space.
  • OnRestart(): It is called when activity has been stopped and before it starts again. 
Suggested Papers: