The android activity lifecycle includes the following callbacks:
The lifecycle of an android activity begins here. This is where any layout resources (Buttons, textViews, editText, etc.) and background threads are initialized.
Called right after onCreate(). In this state the activity becomes visible to the user.
Called after an activity has been stopped. This call reverts the activity to its visible lifetime.
Called when the user returns to an activity after briefly exiting it. The app stays in this state until something happens to take focus away from the app. Such an event might be, for instance, receiving a phone call, the user’s navigating to another activity, or the device screen’s turning off.
Called when the user leaves the current activity to another activity or leaves the app for a while. It indicates that the activity is no longer in the foreground and certain processes that are not needed while the activity is not in the foreground will be stopped.
Called when the activiy becomes invisible to the user. The activity and its resources may still be running in the background even though it is not visible. After onStop() is called, the activity will call onRestart() if it needs to be loaded again.
The end of the activity lifecycle. This activity is used to stop all resources and tasks started in onCreate(). After onDestroy() is called, the activity will call onCreate() if it needs to be loaded again.
The system invokes this callback either because:
- The activity is finishing (due to the user completely dismissing the activity or due to finish() being called on the activity), or
- The system is temporarily destroying the activity due to a configuration change (such as device rotation or multi-window mode)
You can learn more about android life cycle here !