Day 5: Mastering Activities & Intents in Android Development

Welcome to Day 5 of the 90-Day Android Developer Challenge on HandsOnAndroid.com!
Today, we explore Activities and Intents, the core building blocks for screen navigation in Android apps.

By the end of this guide, you’ll be able to:

  • Launch new screens
  • Pass data between Activities
  • Use both Explicit and Implicit Intents

🧱 What is an Activity?

An Activity is a single screen in your Android app — like a page in a book.
Every Android app must have at least one activity, typically MainActivity.

🔹 Activities manage:

  • UI (via XML or Compose)
  • User interaction
  • The screen lifecycle

🚀 What is an Intent?

An Intent is how you request Android to:

  • Open another activity (screen)
  • Open a web browser
  • Send data between apps

🧭 Types of Intents:

  1. Explicit Intent → You specify the target component
  2. Implicit Intent → You let Android find a suitable app

✏️ Kotlin Example: Launching an Activity

val intent = Intent(this, ProfileActivity::class.java)
intent.putExtra("username", "firoj")
startActivity(intent)

In ProfileActivity.kt:

val username = intent.getStringExtra("username")

💡 Bonus: Implicit Intent Example

val urlIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://handsonandroid.com"))
startActivity(urlIntent)

🔄 Activity Navigation Diagram

📌 Imagine a flow:
MainActivityLoginActivityDashboardActivity
Each is connected via an Intent.


🧭 Continue Your Android Developer Journey

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top