The Activity lifecycle
In Chapter 1, Creating Your First App, we used the onCreate(saveInstanceState: Bundle?)
method to display the Composable UI for our screen. Now, we’ll explore in more detail how the Android system interacts with your application to make this happen. As soon as an Activity is launched, it goes through a series of steps to take it through initialization, from preparing to be displayed to being partially displayed and then being fully visible.There are also steps that correspond with your application being hidden, backgrounded, and then destroyed. This process is called the Activity lifecycle. For every one of these steps, there is a callback that your Activity can use to perform actions such as creating and changing the display, saving data when your app has been put into the background, and then restoring that data after your app comes back into the foreground.These callbacks are made on the parent Activity, and it’s up to you to decide...