onCreate(), Activity, Bundle

Life cycle of activity


  • entire lifetime
    • happens between the first call to onCreate(Bundle)through to a single final call to onDestroy()
  • visible lifetime
    • happens between a call to onStart() until a corresponding call to onStop(). During this time the user can see the activity on-screen, though it may not be in the foreground and interacting with the user.
  • foreground lifetime
    • happens between a call to onResume() until a corresponding call to onPause(). During this time the activity is in front of all other activities and interacting with the user. An activity can frequently go between the resumed and paused states


  • onCreate() – Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc.
    • setContentView
  • onRestart() – Called after your activity has been stopped, prior to it being started again. Always followed by onStart()
  • onStart() – Called when the activity is becoming visible to the user. Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.
  • onResume() – Called when the activity will start interacting with the user. At this point your activity is at the top of the activity stack.
  • onPause() – Called when the system is about to start resuming a previous activity. This is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU.
  • onStop() – Called when the activity is no longer visible to the user, because another activity has been resumed and is covering this one.
  • onDestroy() – The final call you receive before your activity is destroyed. This can happen either because the activity is finishing


  • bundle in onCreate parameter
    • gives information when creating activity
    • Initially set to null
    • In the case that calling onCreate method after onStop(), and also it was killed not intentionally, it gives current status information for onCreate()


  • setContentView()
    • sets actual view which users will see
  • onSaveInstanceState(Bundle)
    • called when activity abnormally becomes onStop() state
    • store instance status information
    • When activity is being initialized again, calls the bundle information which onSaveInstanceState() had saved.
  • onRestoreInstanceState(Bundle)
    • called when activity abnormally becomes onStop() state and becomes back onResume() state


Leave A Comment

Your email address will not be published. Required fields are marked *