Activity — what it is, Android app screen and its Lifecycle

Author: IT Sectr Published: 2026-02-22 Reading time: 7 min

Activity — a basic Android application component representing a single screen with a user interface. The system manages screens through a strict lifecycle — callbacks onCreate, onResume, and onDestroy. Each Activity is declared in AndroidManifest.xml and launched via Intent. Read more about the history of Android in the official Google documentation.

Key Takeaways

  • Activity — an Android component representing a single screen with UI. Managed through Lifecycle
  • Lifecycle includes 6 callbacks: onCreate, onStart, onResume, onPause, onStop, onDestroy
  • Intent — a mechanism for launching Activity and passing data between screens
  • Manifest — mandatory registration of each Activity in AndroidManifest.xml
  • ViewModel — a Jetpack component for preserving data when recreating Activity

What is Activity?

Activity — a key Android application component that provides a window for user interaction. Each Activity manages a separate screen: task list, login form, photo viewer. The Android system creates an Activity when requested and destroys it when memory is needed by other applications.

Activity first appeared in Android 1.0 (2008) and remains the main building block of the interface. According to Google (2026), 98% of apps on Google Play contain at least one Activity. In modern architecture, Google recommends one Activity with multiple Fragments, however the classic multi-screen application remains a common practice.

Activity stack (back stack) — a task stack that stores navigation history. When the user presses "Back", the current Activity is destroyed and the previous one is restored. The system manages the stack automatically, but the developer can control behavior through launchMode and Intent flags.

Activity Lifecycle

The Activity lifecycle is a set of states and callbacks through which a screen passes from creation to destruction. Understanding the Lifecycle is critically important: incorrect state handling leads to memory leaks, data loss, and app crashes.

The Android system calls callbacks in a strict order. The developer overrides the necessary methods to initialize resources, save data, and free memory. Each callback has a corresponding pair: onCreate ↔ onDestroy, onStart ↔ onStop, onResume ↔ onPause.

CallbackPurposeDeveloper Action
onCreateCalled when Activity is createdUI initialization, subscribing to ViewModel
onStartActivity becomes visibleStart animations, camera, GPS
onResumeActivity gets input focusResume video, timers
onPauseActivity loses focusSave drafts, stop animations
onStopActivity is hidden by another screenRelease heavy resources
onDestroyActivity is destroyedClean up subscriptions, Closeable

Activity States

There are four states of Activity: Running (onResume active), Paused (visible but without focus), Stopped (not visible), Destroyed (destroyed). The system can kill an Activity in the Stopped state when memory is low — data must be saved in onSaveInstanceState.

Lifecycle methods: onCreate, onStart, onResume

Let's look at three key Activity lifecycle methods with a Kotlin example. onCreate — the entry point, called once. Here layout binding via setContentView, RecyclerView initialization, LiveData subscription happen. onStart — the Activity becomes visible to the user. onResume — the Activity gets focus and is ready for interaction.

kotlin
class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val recyclerView = findViewById<RecyclerView>(R.id.rv_items)
        recyclerView.layoutManager = LinearLayoutManager(this)
        loadItems()
    }

    override fun onStart() {
        super.onStart()
        startLocationUpdates()
    }

    override fun onResume() {
        super.onResume()
        resumeVideoPlayer()
    }
}

In the example, onCreate initializes RecyclerView and loads data. onStart starts geolocation updates — a resource that should only work when the screen is visible. onResume resumes the video that was paused in onPause. This separation prevents unnecessary background work.

Declaring Activity in AndroidManifest.xml

Each Activity must be declared in the AndroidManifest.xml file. Without registration, the system won't find the screen and will throw an ActivityNotFoundException. The manifest specifies the class name, theme, orientation, launchMode, and Intent filters.

xml
<application
    android:allowBackup="true"
    android:label="@string/app_name"
    android:theme="@style/Theme.MyApp">

    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".DetailActivity"
        android:parentActivityName=".MainActivity" />
</application>

The exported flag determines whether other applications can launch the Activity. For the main screen exported=true, for internal screens — false. The parentActivityName attribute enables standard Up Navigation.

Launching Activity via Intent

Intent — an object that describes an action to perform. In the context of Activity, Intent is used to launch another screen with data passing. Intent can be explicit (specifies a specific class) and implicit (specifies an action, the system selects a suitable component).

kotlin
// Explicit Intent — launching DetailActivity with data
val intent = Intent(this, DetailActivity::class.java).apply {
    putExtra("item_id", itemId)
    putExtra("item_name", itemName)
}
startActivity(intent)

// Getting data in DetailActivity
val itemId = intent.getLongExtra("item_id", 0L)
val itemName = intent.getStringExtra("item_name") ?: ""

To get a result from a launched Activity, the Activity Result API is used, which replaced the deprecated startActivityForResult. The new API is type-safe, declarative, and works with Jetpack Compose.

kotlin
private val getResult = registerForActivityResult(
    ActivityResultContracts.StartActivityForResult()
) { result ->
    if (result.resultCode == Activity.RESULT_OK) {
        val data = result.data?.getStringExtra("result_key")
    }
}

fun openPicker() {
    val intent = Intent(this, PickerActivity::class.java)
    getResult.launch(intent)
}

Saving state on recreation

When the screen rotates or configuration changes, Android recreates the Activity — sequentially calls onDestroy and onCreate. Without state saving, the user loses entered data, scroll position, and selected items. Android provides two mechanisms to solve this problem: onSaveInstanceState and ViewModel.

onSaveInstanceState saves simple data in Bundle before onDestroy is called. ViewModel from Jetpack survives Activity recreation and stores data in memory, which is more efficient for complex objects and network requests.

kotlin
class MainActivity : AppCompatActivity() {

    private val viewModel: MainViewModel by viewModels()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // ViewModel automatically saves data
        viewModel.items.observe(this) { items ->
            updateAdapter(items)
        }
    }

    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        outState.putInt("scroll_position", recyclerView.computeVerticalScrollOffset())
    }
}

Single Activity Architecture and Jetpack

Google's modern approach is Single Activity architecture with one Activity and multiple Fragments. The app uses one MainActivity, and all navigation is handled by Navigation Component through NavHostFragment. Advantages: centralized navigation, shared ViewModel per screen, correct Deep Links handling.

Jetpack Navigation Component automates back stack management, transition animations, and argument passing. NavHostFragment is placed in the Activity layout, and the navigation graph (NavGraph) describes all screens and connections between them. This approach is recommended by Google for new projects and follows Material Design principles.

kotlin
class MainActivity : AppCompatActivity() {

    private val navController by lazy {
        findViewById<NavHostFragment>(R.id.nav_host_fragment)
            .navController
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Setting up NavigationUI for AppBar
        setupActionBarWithNavController(navController)
    }

    override fun onSupportNavigateUp() = 
        navController.navigateUp() || super.onSupportNavigateUp()
}

Frequently Asked Questions

How is Activity different from Fragment?

Activity — a full-fledged application screen with its own lifecycle. Fragment — a part of UI inside Activity that survives Activity recreation and depends on its Lifecycle. Activity is mandatory, Fragment is optional.

How many Activities can be in one application?

There are no limits. Each screen usually represents a separate Activity. A simple app needs one, for multi-screen apps — from 5 to 20. Google recommends one Activity with multiple Fragments.

What is launchMode in Activity?

launchMode determines how an Activity is created in the task stack. Four modes: standard (a new instance is created), singleTop, singleTask (one instance per task), and singleInstance (isolated task). The mode is set in AndroidManifest.xml.

How to pass data between Activities?

Via Intent — an object with extras (putExtra) that can contain primitives, strings, Parcelable or Serializable. For callbacks, the Activity Result API is used — a modern type-safe replacement for startActivityForResult.

What is Configuration Change in Android?

Configuration Change — recreation of Activity when configuration changes (screen rotation, language change, keyboard). The system calls onDestroy → onCreate. To save data, use onSaveInstanceState or ViewModel from Jetpack.

Summary

  • Activity — a basic Android component representing a single screen with a user interface managed through a lifecycle
  • Lifecycle consists of six callbacks: onCreate, onStart, onResume, onPause, onStop, onDestroy — each has a strict purpose
  • Intent provides Activity launch and data transfer between screens through explicit and implicit calls
  • AndroidManifest.xml requires mandatory registration of each Activity with name, theme, orientation, and filters
  • ViewModel from Jetpack preserves data when Activity is recreated, replacing manual saving in onSaveInstanceState
  • Single Activity architecture with Navigation Component is the modern standard recommended by Google for Android projects
  • launchMode controls Activity behavior in the task stack: from standard to singleInstance for isolated screens

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also