Friday, 21 August 2015

What are the life cycle methods of android activity?

There are 7 life-cycle methods of activity. They are as follows:

onCreate()
onStart()
onResume()
onPause()
onStop()
onRestart()
onDestroy()


  1. onCreate() This is the first callback and called when the activity is first created.
  2. onStart()         This callback is called when the activity becomes visible to the user.
  3. onResume() This is called when the user starts interacting with the application.
  4. onPause()  The paused activity does not receive user input and cannot execute any code and called when the current activity is being paused and the previous activity is being resumed.
  5. onStop() This callback is called when the activity is no longer visible.
  6. onDestroy() This callback is called before the activity is destroyed by the system.
  7. onRestart() This callback is called when the activity restarts after stopping it.




No comments:

Post a Comment