This lesson explains what Android activity is.

Activity is one of the core components of the Android; it represents one screen of the application user interface.

Usually, an Android application consists of several activities, e.g. “Travel Blog” application may contain the following activities:

  • LoginActivity - represents login flow
  • ListActivity - represents a list of recent article titles
  • DetailActivity - represents an article itself

Activities can be launched on top of each other, forming an activity back stack. Users can navigate through this back stack via UI (User Interface) components or navigate back via the system back button.

The activity has its own lifecycle, which helps the developer to understand when an activity is created or destroyed, becomes visible or hidden, recreated or rotated.

To create an activity, we need to create a Java class and extend it from the Activity superclass. Here is an example of MainActivity in the com.travelblog package.

Get hands-on with 1200+ tech skills courses.