We've learnt how to build complex functionality into an app, but we've been restricted to one screen till now. As mentioned before, each screen in an Android app is what's called an Activity. To start working with multiple screens, we need to understand activities.
An activity is a fully featured part of the app, which occupies the entire screen. MainActivity is an activity, and the only one in our app at present. Each new screen in your app will be represented by its own activity, and we will move between screens them by starting one activity from another.
When the app is running, a variety of things can happen to it. The app is opened; the app is minimized; a different app is launched from the notification tray; the app is completely closed. It is the job of the current activity to manage these events. This is known as the Activity Lifecyle. The activity goes through various states during these processes, and following these states allows us to respond to each event appropriately. Here is a diagram of the Activity Lifecycle:
As you can see, the activity goes through different states. For example, onCreate() is only called when the activity is first created. This is why it is a good place to do setup, like we've seen. onResume() is called whenever the activity is made visible. So this is a good place to perhaps refresh the UI, so that if the user minimizes the app and then opens it again the UI is updated.
[how to create activity]
We will see practical code examples in the next section, when we learn how to launch a new activity.
Reading: Read through the documentation for Activity: https://developer.android.com/reference/android/app/Activity.html. Read the article up to and including Activity Lifecycle. If you want to see some practical code samples for the lifecycle methods, this article has examples: https://developer.android.com/guide/components/activities/activity-lifecycle.html.
There will be terms that are new to you in the article. Try to read it anyway and understand the concepts being describe (with the help of some Googling if necessary). Some of these concepts will be clearer when we learn about classes next week.