@capawesome/capacitor-android-intent-launcher 0.0.1
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/CapawesomeCapacitorAndroidIntentLauncher.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +242 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/AndroidIntentLauncher.java +106 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/AndroidIntentLauncherPlugin.java +103 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/classes/CustomExceptions.java +11 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/classes/options/IntentOptions.java +110 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/classes/results/CanResolveActivityResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/classes/results/StartActivityResult.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidintentlauncher/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +296 -0
- package/dist/esm/definitions.d.ts +164 -0
- package/dist/esm/definitions.js +19 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +6 -0
- package/dist/esm/web.js +10 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +43 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +46 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/AndroidIntentLauncherPlugin.swift +24 -0
- package/ios/Plugin/Info.plist +24 -0
- package/package.json +91 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidintentlauncher.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSArray;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import com.getcapacitor.PluginCall;
|
|
8
|
+
import io.capawesome.capacitorjs.plugins.androidintentlauncher.classes.CustomExceptions;
|
|
9
|
+
import java.util.List;
|
|
10
|
+
import org.json.JSONException;
|
|
11
|
+
|
|
12
|
+
public class IntentOptions {
|
|
13
|
+
|
|
14
|
+
@NonNull
|
|
15
|
+
private final String action;
|
|
16
|
+
|
|
17
|
+
@Nullable
|
|
18
|
+
private final List<String> categories;
|
|
19
|
+
|
|
20
|
+
@Nullable
|
|
21
|
+
private final String className;
|
|
22
|
+
|
|
23
|
+
@Nullable
|
|
24
|
+
private final String dataUri;
|
|
25
|
+
|
|
26
|
+
@Nullable
|
|
27
|
+
private final JSObject extras;
|
|
28
|
+
|
|
29
|
+
@Nullable
|
|
30
|
+
private final Integer flags;
|
|
31
|
+
|
|
32
|
+
@Nullable
|
|
33
|
+
private final String packageName;
|
|
34
|
+
|
|
35
|
+
@Nullable
|
|
36
|
+
private final String type;
|
|
37
|
+
|
|
38
|
+
public IntentOptions(@NonNull PluginCall call) throws Exception {
|
|
39
|
+
this.action = getActionFromCall(call);
|
|
40
|
+
this.categories = getCategoriesFromCall(call);
|
|
41
|
+
this.className = call.getString("className");
|
|
42
|
+
this.dataUri = call.getString("dataUri");
|
|
43
|
+
this.extras = call.getObject("extras");
|
|
44
|
+
this.flags = call.getInt("flags");
|
|
45
|
+
this.packageName = call.getString("packageName");
|
|
46
|
+
this.type = call.getString("type");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@NonNull
|
|
50
|
+
public String getAction() {
|
|
51
|
+
return action;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Nullable
|
|
55
|
+
public List<String> getCategories() {
|
|
56
|
+
return categories;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Nullable
|
|
60
|
+
public String getClassName() {
|
|
61
|
+
return className;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Nullable
|
|
65
|
+
public String getDataUri() {
|
|
66
|
+
return dataUri;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Nullable
|
|
70
|
+
public JSObject getExtras() {
|
|
71
|
+
return extras;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Nullable
|
|
75
|
+
public Integer getFlags() {
|
|
76
|
+
return flags;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Nullable
|
|
80
|
+
public String getPackageName() {
|
|
81
|
+
return packageName;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Nullable
|
|
85
|
+
public String getType() {
|
|
86
|
+
return type;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@NonNull
|
|
90
|
+
private static String getActionFromCall(@NonNull PluginCall call) throws Exception {
|
|
91
|
+
String action = call.getString("action");
|
|
92
|
+
if (action == null) {
|
|
93
|
+
throw CustomExceptions.ACTION_MISSING;
|
|
94
|
+
}
|
|
95
|
+
return action;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Nullable
|
|
99
|
+
private static List<String> getCategoriesFromCall(@NonNull PluginCall call) {
|
|
100
|
+
JSArray categories = call.getArray("categories");
|
|
101
|
+
if (categories == null) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
return categories.toList();
|
|
106
|
+
} catch (JSONException exception) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidintentlauncher.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.androidintentlauncher.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class CanResolveActivityResult implements Result {
|
|
8
|
+
|
|
9
|
+
private final boolean canResolve;
|
|
10
|
+
|
|
11
|
+
public CanResolveActivityResult(boolean canResolve) {
|
|
12
|
+
this.canResolve = canResolve;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
@NonNull
|
|
17
|
+
public JSObject toJSObject() {
|
|
18
|
+
JSObject result = new JSObject();
|
|
19
|
+
result.put("canResolve", canResolve);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidintentlauncher.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.androidintentlauncher.interfaces.Result;
|
|
7
|
+
import org.json.JSONObject;
|
|
8
|
+
|
|
9
|
+
public class StartActivityResult implements Result {
|
|
10
|
+
|
|
11
|
+
@Nullable
|
|
12
|
+
private final String dataUri;
|
|
13
|
+
|
|
14
|
+
private final int resultCode;
|
|
15
|
+
|
|
16
|
+
public StartActivityResult(int resultCode, @Nullable String dataUri) {
|
|
17
|
+
this.resultCode = resultCode;
|
|
18
|
+
this.dataUri = dataUri;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Override
|
|
22
|
+
@NonNull
|
|
23
|
+
public JSObject toJSObject() {
|
|
24
|
+
JSObject result = new JSObject();
|
|
25
|
+
result.put("resultCode", resultCode);
|
|
26
|
+
result.put("dataUri", dataUri == null ? JSONObject.NULL : dataUri);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "AndroidIntentLauncherPlugin",
|
|
4
|
+
"slug": "androidintentlauncherplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "canResolveActivity",
|
|
10
|
+
"signature": "(options: CanResolveActivityOptions) => Promise<CanResolveActivityResult>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "StartActivityOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<CanResolveActivityResult>",
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "since",
|
|
22
|
+
"text": "0.1.0"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"docs": "Check whether an activity exists that can handle the given intent.\n\nThis is a wrapper around the `PackageManager.resolveActivity(...)` API.\n\nOn Android 11 (API level 30) and higher, the result is affected by\npackage visibility. Your app may need to declare matching `<queries>`\nentries in its `AndroidManifest.xml` for the intent to be resolved.\n\nOnly available on Android.",
|
|
26
|
+
"complexTypes": [
|
|
27
|
+
"CanResolveActivityResult",
|
|
28
|
+
"CanResolveActivityOptions"
|
|
29
|
+
],
|
|
30
|
+
"slug": "canresolveactivity"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "startActivity",
|
|
34
|
+
"signature": "(options: StartActivityOptions) => Promise<StartActivityResult>",
|
|
35
|
+
"parameters": [
|
|
36
|
+
{
|
|
37
|
+
"name": "options",
|
|
38
|
+
"docs": "",
|
|
39
|
+
"type": "StartActivityOptions"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"returns": "Promise<StartActivityResult>",
|
|
43
|
+
"tags": [
|
|
44
|
+
{
|
|
45
|
+
"name": "since",
|
|
46
|
+
"text": "0.1.0"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"docs": "Launch an activity for the given intent.\n\nThe intent is started via the `startActivityForResult(...)` API so the\nresult code and result data of the launched activity are returned once it\nfinishes.\n\nThis is the power-user escape hatch for system screens and app\nintegrations that no dedicated plugin covers. Prefer a typed plugin (such\nas [Settings Launcher](https://capawesome.io/docs/sdks/capacitor/settings-launcher/)\nor [App Launcher](https://capawesome.io/docs/sdks/capacitor/app-launcher/))\nwhere one exists.\n\nOnly available on Android.",
|
|
50
|
+
"complexTypes": [
|
|
51
|
+
"StartActivityResult",
|
|
52
|
+
"StartActivityOptions"
|
|
53
|
+
],
|
|
54
|
+
"slug": "startactivity"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"properties": []
|
|
58
|
+
},
|
|
59
|
+
"interfaces": [
|
|
60
|
+
{
|
|
61
|
+
"name": "CanResolveActivityResult",
|
|
62
|
+
"slug": "canresolveactivityresult",
|
|
63
|
+
"docs": "",
|
|
64
|
+
"tags": [
|
|
65
|
+
{
|
|
66
|
+
"text": "0.1.0",
|
|
67
|
+
"name": "since"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"methods": [],
|
|
71
|
+
"properties": [
|
|
72
|
+
{
|
|
73
|
+
"name": "canResolve",
|
|
74
|
+
"tags": [
|
|
75
|
+
{
|
|
76
|
+
"text": "true",
|
|
77
|
+
"name": "example"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"text": "0.1.0",
|
|
81
|
+
"name": "since"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"docs": "Whether or not an activity exists that can handle the intent.",
|
|
85
|
+
"complexTypes": [],
|
|
86
|
+
"type": "boolean"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "StartActivityOptions",
|
|
92
|
+
"slug": "startactivityoptions",
|
|
93
|
+
"docs": "",
|
|
94
|
+
"tags": [
|
|
95
|
+
{
|
|
96
|
+
"text": "0.1.0",
|
|
97
|
+
"name": "since"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"methods": [],
|
|
101
|
+
"properties": [
|
|
102
|
+
{
|
|
103
|
+
"name": "action",
|
|
104
|
+
"tags": [
|
|
105
|
+
{
|
|
106
|
+
"text": "'android.intent.action.VIEW'",
|
|
107
|
+
"name": "example"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"text": "0.1.0",
|
|
111
|
+
"name": "since"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"docs": "The action of the intent.",
|
|
115
|
+
"complexTypes": [],
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "categories",
|
|
120
|
+
"tags": [
|
|
121
|
+
{
|
|
122
|
+
"text": "['android.intent.category.DEFAULT']",
|
|
123
|
+
"name": "example"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"text": "0.1.0",
|
|
127
|
+
"name": "since"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"docs": "The categories to add to the intent.",
|
|
131
|
+
"complexTypes": [],
|
|
132
|
+
"type": "string[] | undefined"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "className",
|
|
136
|
+
"tags": [
|
|
137
|
+
{
|
|
138
|
+
"text": "'com.example.app.MainActivity'",
|
|
139
|
+
"name": "example"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"text": "0.1.0",
|
|
143
|
+
"name": "since"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"docs": "The fully qualified class name of the component to launch.\n\nMust be used together with the `packageName` property to create an\nexplicit intent that targets a specific component.",
|
|
147
|
+
"complexTypes": [],
|
|
148
|
+
"type": "string | undefined"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "dataUri",
|
|
152
|
+
"tags": [
|
|
153
|
+
{
|
|
154
|
+
"text": "'https://capawesome.io'",
|
|
155
|
+
"name": "example"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"text": "0.1.0",
|
|
159
|
+
"name": "since"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"docs": "The data URI of the intent.",
|
|
163
|
+
"complexTypes": [],
|
|
164
|
+
"type": "string | undefined"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"name": "extras",
|
|
168
|
+
"tags": [
|
|
169
|
+
{
|
|
170
|
+
"text": "{ 'android.intent.extra.TEXT': 'Hello world!' }",
|
|
171
|
+
"name": "example"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"text": "0.1.0",
|
|
175
|
+
"name": "since"
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"docs": "The extras to add to the intent.\n\nOnly primitive values (string, number and boolean) are supported.",
|
|
179
|
+
"complexTypes": [],
|
|
180
|
+
"type": "{ [key: string]: string | number | boolean; } | undefined"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "flags",
|
|
184
|
+
"tags": [
|
|
185
|
+
{
|
|
186
|
+
"text": "268435456",
|
|
187
|
+
"name": "example"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"text": "0.1.0",
|
|
191
|
+
"name": "since"
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
"docs": "The flags to add to the intent.\n\nMultiple flags can be combined using the bitwise OR operator.",
|
|
195
|
+
"complexTypes": [],
|
|
196
|
+
"type": "number | undefined"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "packageName",
|
|
200
|
+
"tags": [
|
|
201
|
+
{
|
|
202
|
+
"text": "'com.example.app'",
|
|
203
|
+
"name": "example"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"text": "0.1.0",
|
|
207
|
+
"name": "since"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"docs": "The package name of the component to launch.\n\nIf used without the `className` property, the intent is restricted to the\ngiven package. If used together with the `className` property, an explicit\nintent that targets a specific component is created.",
|
|
211
|
+
"complexTypes": [],
|
|
212
|
+
"type": "string | undefined"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"name": "type",
|
|
216
|
+
"tags": [
|
|
217
|
+
{
|
|
218
|
+
"text": "'text/plain'",
|
|
219
|
+
"name": "example"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"text": "0.1.0",
|
|
223
|
+
"name": "since"
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"docs": "The MIME type of the intent data.",
|
|
227
|
+
"complexTypes": [],
|
|
228
|
+
"type": "string | undefined"
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"name": "StartActivityResult",
|
|
234
|
+
"slug": "startactivityresult",
|
|
235
|
+
"docs": "",
|
|
236
|
+
"tags": [
|
|
237
|
+
{
|
|
238
|
+
"text": "0.1.0",
|
|
239
|
+
"name": "since"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"methods": [],
|
|
243
|
+
"properties": [
|
|
244
|
+
{
|
|
245
|
+
"name": "dataUri",
|
|
246
|
+
"tags": [
|
|
247
|
+
{
|
|
248
|
+
"text": "'content://com.example.app/1'",
|
|
249
|
+
"name": "example"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"text": "0.1.0",
|
|
253
|
+
"name": "since"
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
"docs": "The data URI returned by the launched activity.",
|
|
257
|
+
"complexTypes": [],
|
|
258
|
+
"type": "string | null"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "resultCode",
|
|
262
|
+
"tags": [
|
|
263
|
+
{
|
|
264
|
+
"text": "-1",
|
|
265
|
+
"name": "example"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"text": "0.1.0",
|
|
269
|
+
"name": "since"
|
|
270
|
+
}
|
|
271
|
+
],
|
|
272
|
+
"docs": "The result code returned by the launched activity.\n\nThe value is `-1` if the activity finished successfully (`RESULT_OK`), `0`\nif it was canceled (`RESULT_CANCELED`) or any other custom result code set\nby the launched activity.",
|
|
273
|
+
"complexTypes": [],
|
|
274
|
+
"type": "number"
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
],
|
|
279
|
+
"enums": [],
|
|
280
|
+
"typeAliases": [
|
|
281
|
+
{
|
|
282
|
+
"name": "CanResolveActivityOptions",
|
|
283
|
+
"slug": "canresolveactivityoptions",
|
|
284
|
+
"docs": "",
|
|
285
|
+
"types": [
|
|
286
|
+
{
|
|
287
|
+
"text": "StartActivityOptions",
|
|
288
|
+
"complexTypes": [
|
|
289
|
+
"StartActivityOptions"
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
],
|
|
295
|
+
"pluginConfigs": []
|
|
296
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export interface AndroidIntentLauncherPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Check whether an activity exists that can handle the given intent.
|
|
4
|
+
*
|
|
5
|
+
* This is a wrapper around the `PackageManager.resolveActivity(...)` API.
|
|
6
|
+
*
|
|
7
|
+
* On Android 11 (API level 30) and higher, the result is affected by
|
|
8
|
+
* package visibility. Your app may need to declare matching `<queries>`
|
|
9
|
+
* entries in its `AndroidManifest.xml` for the intent to be resolved.
|
|
10
|
+
*
|
|
11
|
+
* Only available on Android.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
canResolveActivity(options: CanResolveActivityOptions): Promise<CanResolveActivityResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Launch an activity for the given intent.
|
|
18
|
+
*
|
|
19
|
+
* The intent is started via the `startActivityForResult(...)` API so the
|
|
20
|
+
* result code and result data of the launched activity are returned once it
|
|
21
|
+
* finishes.
|
|
22
|
+
*
|
|
23
|
+
* This is the power-user escape hatch for system screens and app
|
|
24
|
+
* integrations that no dedicated plugin covers. Prefer a typed plugin (such
|
|
25
|
+
* as [Settings Launcher](https://capawesome.io/docs/sdks/capacitor/settings-launcher/)
|
|
26
|
+
* or [App Launcher](https://capawesome.io/docs/sdks/capacitor/app-launcher/))
|
|
27
|
+
* where one exists.
|
|
28
|
+
*
|
|
29
|
+
* Only available on Android.
|
|
30
|
+
*
|
|
31
|
+
* @since 0.1.0
|
|
32
|
+
*/
|
|
33
|
+
startActivity(options: StartActivityOptions): Promise<StartActivityResult>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @since 0.1.0
|
|
37
|
+
*/
|
|
38
|
+
export interface StartActivityOptions {
|
|
39
|
+
/**
|
|
40
|
+
* The action of the intent.
|
|
41
|
+
*
|
|
42
|
+
* @example 'android.intent.action.VIEW'
|
|
43
|
+
* @since 0.1.0
|
|
44
|
+
*/
|
|
45
|
+
action: string;
|
|
46
|
+
/**
|
|
47
|
+
* The categories to add to the intent.
|
|
48
|
+
*
|
|
49
|
+
* @example ['android.intent.category.DEFAULT']
|
|
50
|
+
* @since 0.1.0
|
|
51
|
+
*/
|
|
52
|
+
categories?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* The fully qualified class name of the component to launch.
|
|
55
|
+
*
|
|
56
|
+
* Must be used together with the `packageName` property to create an
|
|
57
|
+
* explicit intent that targets a specific component.
|
|
58
|
+
*
|
|
59
|
+
* @example 'com.example.app.MainActivity'
|
|
60
|
+
* @since 0.1.0
|
|
61
|
+
*/
|
|
62
|
+
className?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The data URI of the intent.
|
|
65
|
+
*
|
|
66
|
+
* @example 'https://capawesome.io'
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
*/
|
|
69
|
+
dataUri?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The extras to add to the intent.
|
|
72
|
+
*
|
|
73
|
+
* Only primitive values (string, number and boolean) are supported.
|
|
74
|
+
*
|
|
75
|
+
* @example { 'android.intent.extra.TEXT': 'Hello world!' }
|
|
76
|
+
* @since 0.1.0
|
|
77
|
+
*/
|
|
78
|
+
extras?: {
|
|
79
|
+
[key: string]: string | number | boolean;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* The flags to add to the intent.
|
|
83
|
+
*
|
|
84
|
+
* Multiple flags can be combined using the bitwise OR operator.
|
|
85
|
+
*
|
|
86
|
+
* @example 268435456
|
|
87
|
+
* @since 0.1.0
|
|
88
|
+
*/
|
|
89
|
+
flags?: number;
|
|
90
|
+
/**
|
|
91
|
+
* The package name of the component to launch.
|
|
92
|
+
*
|
|
93
|
+
* If used without the `className` property, the intent is restricted to the
|
|
94
|
+
* given package. If used together with the `className` property, an explicit
|
|
95
|
+
* intent that targets a specific component is created.
|
|
96
|
+
*
|
|
97
|
+
* @example 'com.example.app'
|
|
98
|
+
* @since 0.1.0
|
|
99
|
+
*/
|
|
100
|
+
packageName?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The MIME type of the intent data.
|
|
103
|
+
*
|
|
104
|
+
* @example 'text/plain'
|
|
105
|
+
* @since 0.1.0
|
|
106
|
+
*/
|
|
107
|
+
type?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @since 0.1.0
|
|
111
|
+
*/
|
|
112
|
+
export interface StartActivityResult {
|
|
113
|
+
/**
|
|
114
|
+
* The data URI returned by the launched activity.
|
|
115
|
+
*
|
|
116
|
+
* @example 'content://com.example.app/1'
|
|
117
|
+
* @since 0.1.0
|
|
118
|
+
*/
|
|
119
|
+
dataUri: string | null;
|
|
120
|
+
/**
|
|
121
|
+
* The result code returned by the launched activity.
|
|
122
|
+
*
|
|
123
|
+
* The value is `-1` if the activity finished successfully (`RESULT_OK`), `0`
|
|
124
|
+
* if it was canceled (`RESULT_CANCELED`) or any other custom result code set
|
|
125
|
+
* by the launched activity.
|
|
126
|
+
*
|
|
127
|
+
* @example -1
|
|
128
|
+
* @since 0.1.0
|
|
129
|
+
*/
|
|
130
|
+
resultCode: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @since 0.1.0
|
|
134
|
+
*/
|
|
135
|
+
export type CanResolveActivityOptions = StartActivityOptions;
|
|
136
|
+
/**
|
|
137
|
+
* @since 0.1.0
|
|
138
|
+
*/
|
|
139
|
+
export interface CanResolveActivityResult {
|
|
140
|
+
/**
|
|
141
|
+
* Whether or not an activity exists that can handle the intent.
|
|
142
|
+
*
|
|
143
|
+
* @example true
|
|
144
|
+
* @since 0.1.0
|
|
145
|
+
*/
|
|
146
|
+
canResolve: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @since 0.1.0
|
|
150
|
+
*/
|
|
151
|
+
export declare enum ErrorCode {
|
|
152
|
+
/**
|
|
153
|
+
* No activity was found that can handle the intent.
|
|
154
|
+
*
|
|
155
|
+
* @since 0.1.0
|
|
156
|
+
*/
|
|
157
|
+
ActivityNotFound = "ACTIVITY_NOT_FOUND",
|
|
158
|
+
/**
|
|
159
|
+
* The activity could not be started.
|
|
160
|
+
*
|
|
161
|
+
* @since 0.1.0
|
|
162
|
+
*/
|
|
163
|
+
StartFailed = "START_FAILED"
|
|
164
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 0.1.0
|
|
3
|
+
*/
|
|
4
|
+
export var ErrorCode;
|
|
5
|
+
(function (ErrorCode) {
|
|
6
|
+
/**
|
|
7
|
+
* No activity was found that can handle the intent.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
*/
|
|
11
|
+
ErrorCode["ActivityNotFound"] = "ACTIVITY_NOT_FOUND";
|
|
12
|
+
/**
|
|
13
|
+
* The activity could not be started.
|
|
14
|
+
*
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
*/
|
|
17
|
+
ErrorCode["StartFailed"] = "START_FAILED";
|
|
18
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
19
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAwJA;;GAEG;AACH,MAAM,CAAN,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB;;;;OAIG;IACH,oDAAuC,CAAA;IACvC;;;;OAIG;IACH,yCAA4B,CAAA;AAC9B,CAAC,EAbW,SAAS,KAAT,SAAS,QAapB","sourcesContent":["export interface AndroidIntentLauncherPlugin {\n /**\n * Check whether an activity exists that can handle the given intent.\n *\n * This is a wrapper around the `PackageManager.resolveActivity(...)` API.\n *\n * On Android 11 (API level 30) and higher, the result is affected by\n * package visibility. Your app may need to declare matching `<queries>`\n * entries in its `AndroidManifest.xml` for the intent to be resolved.\n *\n * Only available on Android.\n *\n * @since 0.1.0\n */\n canResolveActivity(\n options: CanResolveActivityOptions,\n ): Promise<CanResolveActivityResult>;\n /**\n * Launch an activity for the given intent.\n *\n * The intent is started via the `startActivityForResult(...)` API so the\n * result code and result data of the launched activity are returned once it\n * finishes.\n *\n * This is the power-user escape hatch for system screens and app\n * integrations that no dedicated plugin covers. Prefer a typed plugin (such\n * as [Settings Launcher](https://capawesome.io/docs/sdks/capacitor/settings-launcher/)\n * or [App Launcher](https://capawesome.io/docs/sdks/capacitor/app-launcher/))\n * where one exists.\n *\n * Only available on Android.\n *\n * @since 0.1.0\n */\n startActivity(options: StartActivityOptions): Promise<StartActivityResult>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface StartActivityOptions {\n /**\n * The action of the intent.\n *\n * @example 'android.intent.action.VIEW'\n * @since 0.1.0\n */\n action: string;\n /**\n * The categories to add to the intent.\n *\n * @example ['android.intent.category.DEFAULT']\n * @since 0.1.0\n */\n categories?: string[];\n /**\n * The fully qualified class name of the component to launch.\n *\n * Must be used together with the `packageName` property to create an\n * explicit intent that targets a specific component.\n *\n * @example 'com.example.app.MainActivity'\n * @since 0.1.0\n */\n className?: string;\n /**\n * The data URI of the intent.\n *\n * @example 'https://capawesome.io'\n * @since 0.1.0\n */\n dataUri?: string;\n /**\n * The extras to add to the intent.\n *\n * Only primitive values (string, number and boolean) are supported.\n *\n * @example { 'android.intent.extra.TEXT': 'Hello world!' }\n * @since 0.1.0\n */\n extras?: { [key: string]: string | number | boolean };\n /**\n * The flags to add to the intent.\n *\n * Multiple flags can be combined using the bitwise OR operator.\n *\n * @example 268435456\n * @since 0.1.0\n */\n flags?: number;\n /**\n * The package name of the component to launch.\n *\n * If used without the `className` property, the intent is restricted to the\n * given package. If used together with the `className` property, an explicit\n * intent that targets a specific component is created.\n *\n * @example 'com.example.app'\n * @since 0.1.0\n */\n packageName?: string;\n /**\n * The MIME type of the intent data.\n *\n * @example 'text/plain'\n * @since 0.1.0\n */\n type?: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface StartActivityResult {\n /**\n * The data URI returned by the launched activity.\n *\n * @example 'content://com.example.app/1'\n * @since 0.1.0\n */\n dataUri: string | null;\n /**\n * The result code returned by the launched activity.\n *\n * The value is `-1` if the activity finished successfully (`RESULT_OK`), `0`\n * if it was canceled (`RESULT_CANCELED`) or any other custom result code set\n * by the launched activity.\n *\n * @example -1\n * @since 0.1.0\n */\n resultCode: number;\n}\n\n/**\n * @since 0.1.0\n */\nexport type CanResolveActivityOptions = StartActivityOptions;\n\n/**\n * @since 0.1.0\n */\nexport interface CanResolveActivityResult {\n /**\n * Whether or not an activity exists that can handle the intent.\n *\n * @example true\n * @since 0.1.0\n */\n canResolve: boolean;\n}\n\n/**\n * @since 0.1.0\n */\nexport enum ErrorCode {\n /**\n * No activity was found that can handle the intent.\n *\n * @since 0.1.0\n */\n ActivityNotFound = 'ACTIVITY_NOT_FOUND',\n /**\n * The activity could not be started.\n *\n * @since 0.1.0\n */\n StartFailed = 'START_FAILED',\n}\n"]}
|