Android Development
Intents
Mobile App Development
Android Programming
Software Engineering

What is an Intent in Android?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

In Android, an Intent is a message object that asks the system to perform an action. It is one of the core mechanisms that lets activities, services, and broadcast receivers communicate, both within your app and across app boundaries.

What an Intent Carries

An intent can carry several pieces of information that help Android decide what should happen next.

Common fields include:

  • an action such as viewing content or sending data
  • a target component for explicit launches
  • data, often as a Uri
  • extra values bundled with the request
  • categories and flags that influence how the system resolves or launches the component

At a high level, an intent answers two questions:

  1. what action should happen
  2. which component should handle it

Explicit and Implicit Intents

The first major distinction is between explicit and implicit intents.

An explicit intent names the exact component class to start. This is the normal choice for navigation inside your own app.

kotlin
val intent = Intent(this, DetailsActivity::class.java)
intent.putExtra("item_id", 42)
startActivity(intent)

Here Android does not need to search for a matching app. The destination is fixed.

An implicit intent describes a general action and lets the system choose a matching component based on intent filters.

kotlin
1val intent = Intent(Intent.ACTION_VIEW).apply {
2    data = Uri.parse("https://developer.android.com")
3}
4startActivity(intent)

In this case, Android looks for an app that can handle the request to view that URI.

Where Intents Are Used

Intents are used for three major component interactions.

Activities use intents for screen-to-screen navigation and for handing work to other apps.

Services can be started with intents when background work needs to begin.

Broadcast receivers receive intents representing system or app-defined events.

That makes intents a unifying mechanism across much of the Android component model.

Intent Filters and Resolution

Implicit intents only work when some component has declared that it can handle them. That declaration lives in the manifest through an intent filter.

xml
1<activity android:name=".ShareActivity" android:exported="true">
2    <intent-filter>
3        <action android:name="android.intent.action.SEND" />
4        <category android:name="android.intent.category.DEFAULT" />
5        <data android:mimeType="text/plain" />
6    </intent-filter>
7</activity>

When the system sees an implicit intent, it compares the intent’s action, data, and categories against available filters. If multiple apps match, the user may get a chooser.

This is powerful, but it also has security implications. Exported components should accept only the inputs they actually expect.

Passing Data With Extras

Extras let you attach structured values to an intent.

kotlin
1val intent = Intent(this, EditProfileActivity::class.java).apply {
2    putExtra("user_id", 123)
3    putExtra("read_only", false)
4}
5startActivity(intent)

The receiving component can then read the extras from the intent it was launched with. Use extras for small parameters and identifiers, not for large in-memory objects that should live elsewhere.

Modern Android Practice

A few intent-related habits have changed over time. For example, older code often used startActivityForResult, while modern apps typically use the Activity Result APIs instead. The concept is still the same, though: an intent launches another component, and the result comes back through a structured callback.

Likewise, Android now requires clearer exported-component declarations. If your activity or receiver is meant for internal use only, keep it non-exported unless external launch behavior is truly required.

Common Pitfalls

The most common mistake is using an implicit intent when an explicit one is safer and simpler inside your own app. Internal navigation usually should not depend on the system’s resolution process.

Another common issue is forgetting that implicit intents rely on matching intent filters. If no component can handle the request, the launch fails.

Developers also sometimes pass too much data through extras. Intents are for messages and parameters, not for replacing proper state management.

Finally, treat external intent input as untrusted. If another app can launch your exported component, validate the incoming data instead of assuming it is well formed.

Summary

  • An Android intent is a message object used to request an action from another component.
  • Explicit intents target a specific component, while implicit intents describe a general action.
  • Intents are central to starting activities, services, and broadcast receivers.
  • Extras, data, actions, and flags help define what the request means.
  • Use explicit intents for internal app navigation and validate external intent data carefully.

Course illustration
Course illustration

All Rights Reserved.