Hello, everyone. Last time we talked about the Activity example in Android. This time we will continue with that example. Stop gossiping and return to the truth. Let’s Talk Android!
Guys, in the last chapter, we introduced the direction of the arrows in the Activity lifecycle diagram, starting with onCreate and ending with onDestroy, and the process went smoothly without any hicks. Today, in this chapter, we will introduce the more convoluted arrows in the Activity lifecycle diagram. There are three of these twists and turns, and we’ll look at each of them.
The first twist is from onPause to onResume. As the arrow flows, the Activity gains focus again. It feels good to lose it again. In addition, we can see the Activity throughout the process. This is usually the case where there is some window screen blocking part of the Acitivity. For example, pop-up dialog box, input window and so on.
The second twist is from the onStop method to the onRestart method and back to the onStart method. As the arrow flows, the Activity comes back from the background to the foreground again, and after the onStart method has finished running, we can see the Activity. This process is quite common. For example, when we jump from the first Activity to the second Activity, press the back button to return to the first Activity again. This process is exactly the same as the flow of the arrow in the twist.
The third twist is from onPause or onStop to onCreate. This process usually doesn’t happen, except when the system runs out of memory. The system will destroy paused or stopped activities and reclaim the resources they occupy. If you want to use these activities again, you need to recreate them from the onCreate method.
The flow of arrows in the Activity lifecycle diagram is described in this section. You can see that the state of the Activity is constantly changing, and the callback method matching each state is executed.
This is an example of an Activity in Android. If you want to know more about it, listen to the next time.