App Activities

Learn about Android app activities and their life cycle methods.

A single screen of the UI is an activity in Android. An activity serves as an app’s entry point and provides a UI to handle user interactions with the screen. For instance, an email app can have one activity to display new emails, another activity to read emails, and yet another activity to compose new emails. We make one of these activities as the main activity that’s run when the app is launched. The activities work together; however, each activity is independent of the others. Let’s learn about Android activities and their life cycle methods.

Android activities

Unlike most programming paradigms where apps start to run from a main() method, Android initiates an activity’s code by invoking callback methods that represent various stages of an activity’s life cycle. Mobile apps are different from desktop apps because the start of the user’s interaction with the mobile app is nondeterministic. For example, if we open an email app from our home screen, we usually discover a list of emails. However, if we launch the same email app from a saved contact, we can see the email composing screen.

The Activity class

The Activity class is a key component in an Android app that facilitates ...