The life and times of an Android app
We have talked a bit about the structure of our code; we know that we can write classes, and within those classes we have functions, and these functions contain our code, which gets things done. We also know that when we want the code within a function to run (that is, be executed), we call that function by using its name.
Additionally, in Chapter 2, Kotlin, XML, and the UI Designer, we learned that Android itself calls the onCreate
function just before the app is ready to start. We saw this when we output to the logcat window and used the Toast
class to send a pop-up message to the user.
In this chapter, we will examine what happens throughout the lifecycle of every app that we write; that is, when it starts, ends, and the stages in between. What we will see is that Android interacts with our app on numerous occasions each time that it is run.
How Android interacts with our apps
Android interacts with our apps by calling functions that are contained within...