The Activity lifecycle
In the previous chapter, we used the onCreate(saveInstanceState: Bundle?)
method to display a layout in the UI of 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 fully displayed.
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 and 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 your Activity’s parent, and it’s up to you to decide whether...