Activity
Learn what Android activity is.
We'll cover the following
Activity concept
Activity is one of the core components of Android. It represents one screen of the application user interface.
Usually, an Android application consists of several activities, e.g. the “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.
Main activity
To create an activity, we need to create a Kotlin class and extend it from the Activity
superclass. Here is an example of MainActivity
in the com.travelblog
package:
Get hands-on with 1400+ tech skills courses.