Working with implicit intents: opening web URLs through app; sharing media from our app to other apps

Implicit intents describe an action (view a URL, share text) and let Android find an app to handle it, so FestConnect Mobile can open its website in a browser or share an event to any messaging app.

10 min read · 9 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

Reaching beyond your own app

FestConnect Mobile wants two things it cannot do alone: open the fest's WEBSITE (needs a browser) and let users SHARE an event to WhatsApp or email (needs those apps). Your app does not, and should not, contain a browser or a messaging client.

Instead, Android lets your app ASK the system: 'someone open this URL' or 'someone share this text', and the system finds an app that can. This is the implicit intent, and it is how apps cooperate. This lesson covers opening URLs and sharing content, the two implicit-intent patterns the syllabus names, letting FestConnect Mobile plug into the whole device.

Theory

Implicit intents: describe the action

An implicit intent specifies an action (and optionally data), WITHOUT naming a specific app. Android finds a suitable handler.

How does the system know which apps can handle an action? Apps declare intent filters in their manifest, advertising the actions they support (a browser advertises it can handle ACTION_VIEW for web URLs; WhatsApp advertises ACTION_SEND for text). When you fire an implicit intent, Android matches it against these filters and offers the matching apps.

So your app expresses INTENT ('view this', 'send this') and the system connects it to a capable app, without your app knowing or caring which apps the user has installed. This loose coupling is a core Android design strength.

Practical

Open a URL, and share an event

// OPEN A URL: ACTION_VIEW with a web Uri -> opens in a browser
fun openFestWebsite() {
    val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://fest.example"))
    startActivity(intent)   // system finds a browser to handle it
}

// SHARE text to any app (WhatsApp, email, etc.)
fun shareEvent(name: String) {
    val intent = Intent(Intent.ACTION_SEND).apply {
        type = "text/plain"
        putExtra(Intent.EXTRA_TEXT, "Join me for $name at TechnoUtsav!")
    }
    // createChooser shows the app picker ("Share via ...")
    startActivity(Intent.createChooser(intent, "Share event"))
}

Theory

ACTION_VIEW, ACTION_SEND, and the chooser

The two patterns the syllabus names:

  • Open a URL: Intent(Intent.ACTION_VIEW, Uri.parse(url)) then startActivity. ACTION_VIEW with a web URI asks the system to VIEW it, and a browser (or a matching app) opens it
  • Share content: Intent(Intent.ACTION_SEND) with a type ("text/plain" for text, "image/*" for an image) and the content in EXTRA_TEXT (or a media URI). This shares to any app that accepts that type

For sharing, wrap the intent in Intent.createChooser(intent, "Share event") to show the 'Share via...' PICKER, letting the user choose which app. Without the chooser, Android may pick a default. The chooser is the familiar share sheet you see across Android apps: your app triggers it with one implicit intent.

Quiz

FestConnect Mobile wants to let users share an event to whatever messaging app they prefer. Which approach?

  1. Detect and directly launch WhatsApp with an explicit intent
  2. Use an implicit intent (ACTION_SEND with EXTRA_TEXT), optionally wrapped in createChooser, so the system offers all capable apps
  3. Build a messaging feature inside FestConnect
  4. It is impossible to share from an app
Show the answer

Use an implicit intent (ACTION_SEND with EXTRA_TEXT), optionally wrapped in createChooser, so the system offers all capable apps

Sharing to WHATEVER app the user prefers is exactly the job of an IMPLICIT intent: ACTION_SEND with the content in EXTRA_TEXT (and a type), which the system offers to every app that can handle sharing, and createChooser shows the picker so the user selects one. Option A (explicitly targeting WhatsApp) is brittle and wrong-spirited: it assumes WhatsApp is installed and ignores the user's other apps; implicit intents avoid naming a specific app. Option C reinvents messaging pointlessly, your app should COOPERATE with existing apps, not duplicate them. Option D is false. The design lesson: to invoke a CAPABILITY (share, view, call) rather than a specific app, use an implicit intent and let the system connect you to whatever handles it.

Think first

Why not just target WhatsApp directly?

It might seem simpler to launch WhatsApp specifically for sharing. Why is the implicit-intent (let-the-user-choose) approach better? Then tap.

Show the answer

Several reasons. (1) NOT EVERYONE has WhatsApp; a user might prefer Telegram, email, SMS, or Instagram, and hard-targeting WhatsApp fails or excludes them. (2) The implicit-intent + chooser approach respects USER CHOICE: the share sheet shows all their capable apps, and they pick. (3) It is ROBUST: your app does not depend on a specific app being installed or on that app's internal details (which can change and break you). (4) It follows Android's DESIGN philosophy of loose coupling: apps advertise capabilities (via intent filters) and the system connects them, so any capable app works without your app knowing about it. Targeting one app is fragile, presumptuous, and limiting; describing the ACTION and letting the system offer handlers is flexible, respectful, and future-proof. Invoke the capability, not the app.

Watch out

Implicit-intent traps

Hard-targeting a specific app: prefer describing the action and letting the system offer handlers.

No handler available: if no app can handle an implicit intent, startActivity can crash; check with resolveActivity or handle the exception.

Wrong type on ACTION_SEND: set type to text/plain, image/*, etc., matching the content, or apps will not accept it.

Forgetting createChooser: without it, Android may launch a default rather than let the user pick.

Assuming a browser exists: usually safe, but robust apps still handle the no-handler case.

Theory

The app cooperates; now it remembers

FestConnect Mobile can open URLs and share events, plugging into the device's other apps. But it still forgets its own data when closed. The next lesson gives it PERSISTENT storage with SQLite (Android's built-in database), with full CRUD, so registrations survive between sessions, the mobile echo of the databases you built in BCA205, BCA303 and BCA504. Then location and camera add device capabilities.

Summary

Key takeaways

  • An implicit intent specifies an ACTION (and optionally data) without naming an app; the system finds a handler.
  • Apps advertise what they handle via intent filters in their manifest; Android matches your intent to them.
  • Open a URL: Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity, opens in a browser.
  • Share content: Intent(Intent.ACTION_SEND) with a type and EXTRA_TEXT (or media URI).
  • Wrap sharing in Intent.createChooser(intent, title) to show the 'Share via...' app picker.
  • Use implicit intents to invoke a CAPABILITY (share, view), not a specific app: flexible and user-respecting.
  • Memory hook: implicit intent describes the action, the system offers the apps, createChooser lets the user pick.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from JSON, Intent and Storing Android Application data using Database

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Working with implicit intents: opening web URLs through app; sharing media from our app to other apps · Advance Mobile Technology - I (Major-11-02) · Gri-Learn