0Pricing
Android Academy · Lesson

Intents & Navigation

Navigate between Activities with explicit Intents, pass data with putExtra/getExtra, and launch external apps with implicit Intents.

Intents & Navigation is a free Android Academy lesson on CoddyKit — lesson 5 of 7. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Android Academy learning path, one of 7 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is an Intent?

An Intent is a message that tells Android to do something:

  • Explicit Intent — launch a specific Activity in your app
  • Implicit Intent — ask Android to find an app that can handle the action (open a URL, call a number, share text)

Intents are the primary way Activities communicate with each other.

Explicit Intent: Open a Screen

Launch another Activity in your app:

// In your button click listener:
binding.btnGoToDetail.setOnClickListener {
    val intent = Intent(this, DetailActivity::class.java)
    startActivity(intent)
}

// To also close the current screen after navigating:
binding.btnLogin.setOnClickListener {
    val intent = Intent(this, HomeActivity::class.java)
    startActivity(intent)
    finish() // removes LoginActivity from back stack
}

Passing Data with Extras

Use extras to pass data to the next Activity:

  • intent.putExtra("key", value) — attach data
  • intent.getStringExtra("key") — retrieve String
  • intent.getIntExtra("key", defaultValue) — retrieve Int

Use constants for keys to avoid typos.

Passing & Receiving Extras

Send data from one Activity and read it in the next:

// Sending Activity:
val intent = Intent(this, DetailActivity::class.java)
intent.putExtra("PRODUCT_ID", 42)
intent.putExtra("PRODUCT_NAME", "Laptop")
startActivity(intent)

// DetailActivity — receiving:
class DetailActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_detail)

        val id = intent.getIntExtra("PRODUCT_ID", -1)
        val name = intent.getStringExtra("PRODUCT_NAME") ?: ""
        // Use id and name to load data
    }
}

Implicit Intents

Implicit Intents let your app use features from other installed apps without knowing which app handles them:

  • Open a web URL in the browser
  • Dial a phone number
  • Send an email
  • Share text to any app

Android shows a chooser if multiple apps can handle the intent.

Common Implicit Intents

Launch system actions with implicit Intents:

import android.content.Intent
import android.net.Uri

// Open a web page
val webIntent = Intent(Intent.ACTION_VIEW,
    Uri.parse("https://developer.android.com"))
startActivity(webIntent)

// Dial a phone number
val dialIntent = Intent(Intent.ACTION_DIAL,
    Uri.parse("tel:+15551234567"))
startActivity(dialIntent)

// Share text
val shareIntent = Intent(Intent.ACTION_SEND).apply {
    type = "text/plain"
    putExtra(Intent.EXTRA_TEXT, "Check out this app!")
}
startActivity(Intent.createChooser(shareIntent, "Share via"))

Getting Results Back

When you need a result from another screen (e.g. an image picker or form), use the Activity Result API:

  • Register a launcher with registerForActivityResult
  • Launch it when needed
  • Handle the result in a callback

This replaces the old startActivityForResult / onActivityResult pattern.

Result API Example

Request a photo from the gallery and get it back:

import androidx.activity.result.contract.ActivityResultContracts

class MainActivity : AppCompatActivity() {

    private val pickImage = registerForActivityResult(
        ActivityResultContracts.GetContent()
    ) { uri ->
        // 'uri' is the selected image URI, or null if cancelled
        if (uri != null) {
            binding.ivPhoto.setImageURI(uri)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // ...
        binding.btnPickPhoto.setOnClickListener {
            pickImage.launch("image/*")
        }
    }
}

Deep Links

A deep link is a URL that opens a specific screen in your app directly — useful for push notifications and marketing links.

Declare deep links in AndroidManifest.xml using intent-filter with a data tag specifying the URL scheme and host.

Quick Check

Which type of Intent would you use to open a website in the user's browser?

Recap: Intents & Navigation

You can now navigate between screens and launch system features:

  • Explicit Intent — launch a specific Activity in your app
  • putExtra / getExtra — pass data between Activities
  • Implicit Intent — open URLs, dial numbers, share content
  • Activity Result API — receive data back from another Activity

Next up: displaying dynamic lists with RecyclerView.

Frequently asked questions

Is the “Intents & Navigation” lesson free?

Yes — the full text of “Intents & Navigation” is free to read here on the web, and the Android Academy course includes 7 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Android Academy course, upgrade to CoddyKit PRO.

What will I learn in “Intents & Navigation”?

Navigate between Activities with explicit Intents, pass data with putExtra/getExtra, and launch external apps with implicit Intents. You practise Android Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Android Academy?

No prior experience is required. Android Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 5 of 7, so you can start here or from the beginning and move at your own pace.

How long does the “Intents & Navigation” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Android Academy lesson?

Yes. Every Android Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Project Structure & Manifest
  2. Activities & Lifecycle
  3. Layouts & Views
  4. Handling User Input
  5. Intents & Navigation
  6. Fragments
  7. Permissions & Runtime Requests
← Back to Android Academy