Articles → ANDROID → Activity Life Cycle In Android
Activity Life Cycle In Android
Click to Enlarge
- onCreate method
- This method executes immediately after the activity is launched.
- Any initialization in the code will come in this method.
- onStart method - This method is executed
- After the onCreate method.
- When activity is visible to the user.
- onResume method
- This method is called after onRestart and onPause method.
- This method indicates that activity is active and ready to take inputs.
- onPause method
- This method in invoked when activity is in background and not visible to the user.
- onStop method
- This method in executed when activity is in background and not visible to the user (same as onPause).
- This method is executed after the onPause method.
- Operations like writing data into the database could be written inside this method.
- onDestroy method
- This method is executed before the activity is finished.
- Activities could be finished because the programmer is finishing it explicitly or system is destroying the instance to save space.
- onRestart method
- This method is executed once the activity is started after onStop method.
- Once the method is executed, the onStart method is called immediately.