Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Intents and the Other Components  ›  Lesson

Implicit Intents — Asking Other Apps

Implicit Intents 13 minAn implicit intent describes an action and data instead of a class, and the system finds an app that can handle it.

Implicit Intents — Asking Other Apps

Sprout should let users share watering tips with a friend. You could build a messaging feature... or ask the phone's existing apps to do it. Android was designed for the second option.

The rule

Say what to do, not who does it; the system finds the app.

An implicit intent names no class. It describes the job with an action and, usually, some data or a type. The system searches installed apps for one that has declared it can do that job.

val send = Intent(Intent.ACTION_SEND).apply {
    type = "text/plain"
    putExtra(Intent.EXTRA_TEXT, "Water the Monstera every 7 days")
}
startActivity(Intent.createChooser(send, "Share tips"))

Common actions:

  • ACTION_VIEW with a URI — show something: https:// opens a browser, geo: a map.
  • ACTION_SEND with a MIME type — share content.
  • ACTION_DIAL with tel: — open the dialer with a number filled in.

If several apps match, the user picks one. createChooser always shows the picker, which is friendlier for sharing. If no app matches, startActivity throws ActivityNotFoundException, so guard it:

try { startActivity(view) }
catch (e: ActivityNotFoundException) { showMessage("No app can open this") }

The shortcut

Fill in verb + object: "VIEW this web page", "SEND this text", "DIAL this number". The verb is the action; the object is the data or type.

"Look it up" in SproutStep 1 of 4
  1. Verb

    We want to show a page → ACTION_VIEW.

Implicit intents are for other apps. For your own screens, stay explicit: it is faster and nobody else can intercept it.

Drills

Answer fast — trust the rule.

quick drill

What makes an intent implicit?

quick drill

Which action shares a piece of text with another app?

quick drill

Which intent opens a web page in a browser?

quick drill

What happens if you call startActivity with an implicit intent that no installed app can handle?

Remember

  • Say what to do, not who does it; the system finds the app.
  • Build it as verb + object: action plus data or type.
  • Always handle the "no app can do this" case.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainShare and search

Sprout needs a "Share care tips" button and a "Look it up" button that opens a web page about the plant. Describe the intent you would build for each, and what your code must do in case no app on the phone can handle one of them.