Skip to content

Latest commit

 

History

History

README.md

Capacitor Android Intent Launcher Plugin

Capacitor plugin to launch arbitrary Android intents.

Features

  • 🚀 Start activities: Launch any Android activity via a custom intent and read its result.
  • 🔍 Resolve activities: Check whether an activity can handle an intent before launching it.
  • 🎯 Explicit & implicit intents: Target a specific component or let the system pick a handler.
  • 📦 Extras & flags: Attach primitive extras and intent flags.
  • 🤝 Compatibility: Works alongside the Settings Launcher and App Launcher plugins.
  • 🔁 Up-to-date: Always supports the latest Capacitor version.

Missing a feature? Just open an issue and we'll take a look!

Use Cases

The Android Intent Launcher plugin is typically used whenever an app needs to interact with system screens or other apps that no dedicated plugin covers, for example:

  • Opening system screens: Open Android system screens such as the app settings screen via the android.settings.APPLICATION_DETAILS_SETTINGS action.
  • Integrating with other apps: Launch a specific activity of another app via an explicit intent and read its result code and result data once it finishes.
  • Sharing and composing: Share plain text via the android.intent.action.SEND action or compose an email via the android.intent.action.SENDTO action.
  • Feature detection: Check whether an activity exists that can handle an intent before launching it, for example to conditionally show a button in your UI.

Compatibility

Plugin Version Capacitor Version Status
0.x.x >=8.x.x Active support

Installation

You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:

npx skills add capawesome-team/skills --skill capacitor-plugins

Then use the following prompt:

 Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-android-intent-launcher` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capawesome/capacitor-android-intent-launcher
npx cap sync

This plugin is only available on Android. On iOS and Web, all methods reject as unimplemented.

Android

No additional configuration is required for this plugin.

However, on Android 11 (API level 30) and higher, package visibility restricts which apps and intents your app can see. To launch or resolve intents that target other apps, you may need to declare matching <queries> entries in your app's AndroidManifest.xml. See Package visibility below.

iOS

This plugin has no iOS implementation. Intents are an Android-only concept. All methods reject as unimplemented on iOS.

Configuration

No configuration required for this plugin.

Usage

The following examples show how to start an activity for an intent and check whether an intent can be resolved.

Start an activity

Launch an activity for the given intent. The intent is started via the startActivityForResult(...) API, so the result code and result data of the launched activity are returned once it finishes. Only available on Android:

import { AndroidIntentLauncher } from '@capawesome/capacitor-android-intent-launcher';

const startActivity = async () => {
  const { resultCode } = await AndroidIntentLauncher.startActivity({
    action: 'android.intent.action.VIEW',
    dataUri: 'https://capawesome.io',
  });
  return resultCode;
};

Check whether an intent can be resolved

Check whether an activity exists that can handle the given intent before launching it. On Android 11 (API level 30) and higher, the result is affected by package visibility. Only available on Android:

import { AndroidIntentLauncher } from '@capawesome/capacitor-android-intent-launcher';

const canResolveActivity = async () => {
  const { canResolve } = await AndroidIntentLauncher.canResolveActivity({
    action: 'android.intent.action.VIEW',
    dataUri: 'https://capawesome.io',
  });
  return canResolve;
};

API

canResolveActivity(...)

canResolveActivity(options: CanResolveActivityOptions) => Promise<CanResolveActivityResult>

Check whether an activity exists that can handle the given intent.

This is a wrapper around the PackageManager.resolveActivity(...) API.

On Android 11 (API level 30) and higher, the result is affected by package visibility. Your app may need to declare matching &lt;queries&gt; entries in its AndroidManifest.xml for the intent to be resolved.

Only available on Android.

Param Type
options StartActivityOptions

Returns: Promise<CanResolveActivityResult>

Since: 0.1.0


startActivity(...)

startActivity(options: StartActivityOptions) => Promise<StartActivityResult>

Launch an activity for the given intent.

The intent is started via the startActivityForResult(...) API so the result code and result data of the launched activity are returned once it finishes.

This is the power-user escape hatch for system screens and app integrations that no dedicated plugin covers. Prefer a typed plugin (such as Settings Launcher or App Launcher) where one exists.

Only available on Android.

Param Type
options StartActivityOptions

Returns: Promise<StartActivityResult>

Since: 0.1.0


Interfaces

CanResolveActivityResult

Prop Type Description Since
canResolve boolean Whether or not an activity exists that can handle the intent. 0.1.0

StartActivityOptions

Prop Type Description Since
action string The action of the intent. 0.1.0
categories string[] The categories to add to the intent. 0.1.0
className string The fully qualified class name of the component to launch. Must be used together with the packageName property to create an explicit intent that targets a specific component. 0.1.0
dataUri string The data URI of the intent. 0.1.0
extras { [key: string]: string | number | boolean; } The extras to add to the intent. Only primitive values (string, number and boolean) are supported. 0.1.0
flags number The flags to add to the intent. Multiple flags can be combined using the bitwise OR operator. 0.1.0
packageName string The package name of the component to launch. If used without the className property, the intent is restricted to the given package. If used together with the className property, an explicit intent that targets a specific component is created. 0.1.0
type string The MIME type of the intent data. 0.1.0

StartActivityResult

Prop Type Description Since
dataUri string | null The data URI returned by the launched activity. 0.1.0
resultCode number The result code returned by the launched activity. The value is -1 if the activity finished successfully (RESULT_OK), 0 if it was canceled (RESULT_CANCELED) or any other custom result code set by the launched activity. 0.1.0

Type Aliases

CanResolveActivityOptions

StartActivityOptions

Common Intents

The following table lists a few common intents to get you started. See the Android documentation for the full list of actions, categories, extras and flags.

Use case action dataUri type extras
Open a website android.intent.action.VIEW https://capawesome.io
Open the dialer android.intent.action.DIAL tel:+12025550123
Compose an email android.intent.action.SENDTO mailto:hi@example.com { 'android.intent.extra.SUBJECT': 'Hi' }
Share plain text android.intent.action.SEND text/plain { 'android.intent.extra.TEXT': 'Hello world!' }
Open app settings android.settings.APPLICATION_DETAILS_SETTINGS package:com.example.app

This plugin is intended as a last resort for system screens and app integrations that no dedicated plugin covers. Prefer a typed plugin where one exists — for example Settings Launcher for system settings screens or App Launcher for opening URLs and other apps.

Package Visibility

On Android 11 (API level 30) and higher, package visibility limits which other apps your app can interact with. This affects both startActivity(...) (an unresolvable intent rejects with the error code ACTIVITY_NOT_FOUND) and canResolveActivity(...) (which returns false for intents your app cannot see).

If you launch or resolve intents that target other apps, declare the intents you query in your app's AndroidManifest.xml. The plugin cannot predeclare arbitrary intents on your behalf.

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <queries>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="https" />
    </intent>
  </queries>
</manifest>

FAQ

How is this plugin different from other similar plugins?

It launches arbitrary Android intents — explicit or implicit — so you can open system screens or hand off to other apps even when no dedicated plugin covers them, and read the activity result back. You can attach primitive extras and intent flags, and resolve whether an activity can handle an intent before launching it, all through a fully typed API kept current with the latest Capacitor version. When a focused plugin already exists for your target, such as Settings Launcher or App Launcher, that is a fine choice; when you need full control over the raw intent, this plugin is built for it.

Why does startActivity reject with the error code ACTIVITY_NOT_FOUND?

This happens when no activity exists that can handle the given intent. On Android 11 (API level 30) and higher, this can also be caused by package visibility, which limits which other apps your app can see. In that case, declare the intents you query in your app's AndroidManifest.xml using <queries> entries.

Does this plugin work on iOS or Web?

No, intents are an Android-only concept, so this plugin has no iOS or Web implementation. On iOS and Web, all methods reject as unimplemented.

When should I use this plugin instead of a dedicated plugin?

This plugin is intended as a last resort for system screens and app integrations that no dedicated plugin covers. Prefer a typed plugin where one exists, for example Settings Launcher for system settings screens or App Launcher for opening URLs and other apps.

Can I pass complex data as intent extras?

No, only primitive values (string, number and boolean) are supported as intent extras. Intent flags can be attached as well and multiple flags can be combined using the bitwise OR operator.

How do I know whether the launched activity was successful?

The startActivity(...) method resolves with the result code returned by the launched activity once it finishes. The value is -1 if the activity finished successfully (RESULT_OK), 0 if it was canceled (RESULT_CANCELED), or any other custom result code set by the launched activity.

Can I use this plugin with Ionic, React, Vue or Angular?

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

Related Plugins

Newsletter

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.

Changelog

See CHANGELOG.md.

License

See LICENSE.