Skip to the workspace
Pebellslearn by building
Intents and the Other Components  ›  Lesson

Explicit Intents — Opening Your Own Screens

Explicit Intents 13 minAn explicit intent names the exact component to start and can carry small pieces of data as extras.

android / Explicit Intents — Opening Your Own Screens

Explore each scene at your own pace.

01 · The rule

The rule

Explicit Intents — Opening Your Own Screens

The user taps "Monstera" in Sprout's list. The detail screen must open, and it must know which plant to show. Both jobs are done by one small object: an intent.

The rule

Name the class, pack the extras, ask the system.

An intent is a message asking the system to do something, such as start an activity. An explicit intent names the exact component, so there is no doubt who receives it. You use it for screens inside your own app.

// In the list
val intent = Intent(this, PlantDetailActivity::class.java)
intent.putExtra("plant_id", plant.id)
startActivity(intent)
// In PlantDetailActivity.onCreate
val plantId = intent.getLongExtra("plant_id", -1L)
  • Name the class — PlantDetailActivity::class.java is the target.
  • Pack the extras — putExtra(key, value) attaches small values: numbers, strings, booleans.
  • Ask the system — startActivity hands the intent to Android, which starts the activity.

The receiver reads extras with a matching getter and a default value returned when the key is missing. Keep keys in a shared constant so the two sides cannot drift apart.

Extras should stay small. They travel through the system and have a size limit, so send an ID, not a photo. The receiving screen loads the full data itself.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.