When the user navigates, exits, and returns your app, the instances in the app Activity
will transform different states during their life cycle. For example, when your activity first starts, it will appear in the system foreground and receive the user focus. In this process, the Android system invokes a series of life-cycle methods on the activity, through which you can set up the user interface and other components. If a user performs an action that starts another activity or switches to another app, when it enters the background (where activity is no longer visible, but the instance and its state are intact), the system invokes a different set of life-cycle methods on your activity.
Within the life cycle callback method, you can declare the activity behavior of the user when they leave and re-enter the activity. For example, if you are building a streaming video player, you may want to pause the video or terminate the network connection when the user switches to another app. When the user returns, you can reconnect to the network and allow the user to continue playing the video from the same location.
This lesson describes Activity
the important lifecycle callback methods that each instance receives and how you can use them to make your activity work as expected by the user and not consume system resources when your activity does not need them.
Course
-
Start activity
-
Learn the basics about the activity lifecycle, how users start your app, and how to perform basic activity creation operations.
-
Suspend and resume activity
-
Learn what happens when activity pauses (partially hidden) and continues, and what you should do during these state changes.
-
Stop and start the activity again
-
Learn what happens when a user completely leaves your activity and returns to that activity.
-
Re-create activity
-
Learn what happens when your activity is destroyed and how you can reconstruct the activity as needed.
A Management life cycle