@capawesome/capacitor-android-intent-launcher 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -2
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -19,9 +19,14 @@ Capacitor plugin to launch arbitrary Android intents.
|
|
|
19
19
|
|
|
20
20
|
Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Use Cases
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
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:
|
|
25
|
+
|
|
26
|
+
- **Opening system screens**: Open Android system screens such as the app settings screen via the `android.settings.APPLICATION_DETAILS_SETTINGS` action.
|
|
27
|
+
- **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.
|
|
28
|
+
- **Sharing and composing**: Share plain text via the `android.intent.action.SEND` action or compose an email via the `android.intent.action.SENDTO` action.
|
|
29
|
+
- **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.
|
|
25
30
|
|
|
26
31
|
## Compatibility
|
|
27
32
|
|
|
@@ -69,6 +74,12 @@ No configuration required for this plugin.
|
|
|
69
74
|
|
|
70
75
|
## Usage
|
|
71
76
|
|
|
77
|
+
The following examples show how to start an activity for an intent and check whether an intent can be resolved.
|
|
78
|
+
|
|
79
|
+
### Start an activity
|
|
80
|
+
|
|
81
|
+
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:
|
|
82
|
+
|
|
72
83
|
```typescript
|
|
73
84
|
import { AndroidIntentLauncher } from '@capawesome/capacitor-android-intent-launcher';
|
|
74
85
|
|
|
@@ -79,6 +90,14 @@ const startActivity = async () => {
|
|
|
79
90
|
});
|
|
80
91
|
return resultCode;
|
|
81
92
|
};
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Check whether an intent can be resolved
|
|
96
|
+
|
|
97
|
+
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](#package-visibility). Only available on Android:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { AndroidIntentLauncher } from '@capawesome/capacitor-android-intent-launcher';
|
|
82
101
|
|
|
83
102
|
const canResolveActivity = async () => {
|
|
84
103
|
const { canResolve } = await AndroidIntentLauncher.canResolveActivity({
|
|
@@ -233,6 +252,46 @@ If you launch or resolve intents that target other apps, declare the intents you
|
|
|
233
252
|
</manifest>
|
|
234
253
|
```
|
|
235
254
|
|
|
255
|
+
## FAQ
|
|
256
|
+
|
|
257
|
+
### How is this plugin different from other similar plugins?
|
|
258
|
+
|
|
259
|
+
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.
|
|
260
|
+
|
|
261
|
+
### Why does `startActivity` reject with the error code `ACTIVITY_NOT_FOUND`?
|
|
262
|
+
|
|
263
|
+
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](#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.
|
|
264
|
+
|
|
265
|
+
### Does this plugin work on iOS or Web?
|
|
266
|
+
|
|
267
|
+
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.
|
|
268
|
+
|
|
269
|
+
### When should I use this plugin instead of a dedicated plugin?
|
|
270
|
+
|
|
271
|
+
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](https://capawesome.io/docs/sdks/capacitor/settings-launcher/) for system settings screens or [App Launcher](https://capawesome.io/docs/sdks/capacitor/app-launcher/) for opening URLs and other apps.
|
|
272
|
+
|
|
273
|
+
### Can I pass complex data as intent extras?
|
|
274
|
+
|
|
275
|
+
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.
|
|
276
|
+
|
|
277
|
+
### How do I know whether the launched activity was successful?
|
|
278
|
+
|
|
279
|
+
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.
|
|
280
|
+
|
|
281
|
+
### Can I use this plugin with Ionic, React, Vue or Angular?
|
|
282
|
+
|
|
283
|
+
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.
|
|
284
|
+
|
|
285
|
+
## Related Plugins
|
|
286
|
+
|
|
287
|
+
- [Settings Launcher](https://capawesome.io/docs/sdks/capacitor/settings-launcher/): Open native settings screens with a typed API.
|
|
288
|
+
- [App Launcher](https://capawesome.io/docs/sdks/capacitor/app-launcher/): Check if an app can be opened and open it.
|
|
289
|
+
- [File Opener](https://capawesome.io/docs/sdks/capacitor/file-opener/): Open a file with the default application.
|
|
290
|
+
|
|
291
|
+
## Newsletter
|
|
292
|
+
|
|
293
|
+
Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
|
|
294
|
+
|
|
236
295
|
## Changelog
|
|
237
296
|
|
|
238
297
|
See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/android-intent-launcher/CHANGELOG.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/capacitor-android-intent-launcher",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Capacitor plugin to launch arbitrary Android intents.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -36,8 +36,17 @@
|
|
|
36
36
|
"homepage": "https://capawesome.io/docs/sdks/capacitor/android-intent-launcher/",
|
|
37
37
|
"keywords": [
|
|
38
38
|
"capacitor",
|
|
39
|
+
"capacitor-plugin",
|
|
39
40
|
"plugin",
|
|
40
|
-
"native"
|
|
41
|
+
"native",
|
|
42
|
+
"android",
|
|
43
|
+
"intent",
|
|
44
|
+
"android intent",
|
|
45
|
+
"intent launcher",
|
|
46
|
+
"start activity",
|
|
47
|
+
"explicit intent",
|
|
48
|
+
"implicit intent",
|
|
49
|
+
"intent extras"
|
|
41
50
|
],
|
|
42
51
|
"scripts": {
|
|
43
52
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|