Friday, February 17, 2012

Explain Activity LifeCycle in Brief?


These lifecycle methods are:
  • onCreate: the code within the onCreate lifecycle method is called when the activity is instantiated/loaded into memory. This is the method in which you want to set up the intial state of your variables, instantiate the visual objects within the activity via your layout file, and bind your event listeners. If you're a jQuery user, think of it as the equivalent of the document.ready function.
  • onStart: the method called when the activity becomes visible to the user.
  • onResume: the method called when the activity is moved to the foreground of the visible space, when the user is able to not only see the activity but interact with it. After the onResume method is called, the activity is considered to be "running."
  • onPause: called when the activity is no longer in the foreground, usually as the result of another activity being started.
  • onStop: called when the activity is no longer visible to the user in either the foreground or background.
  • onRestart: called when the activity is being restarted (made visible again) after executing onStop but not onDestroy.
  • onDestroy: called just before an activity is destroyed/unloaded from memory.

No comments:

Post a Comment