receive_multi_sharing_intent 1.4.6
receive_multi_sharing_intent: ^1.4.6 copied to clipboard
A flutter plugin that enables flutter apps to receive sharing photos, text or url from other apps.
recieve_multi_sharing_intent #
Forked from https://pub.dev/packages/receive_sharing_intent Refer to the original documentation for ios instructions, and android setup instructions
To support multiple different Intents with the same media type, you have to use ActivityAlias
in your AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
.....
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:name="io.flutter.app.FlutterApplication"
...
>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
...
...
</activity>
<activity-alias
android:name="<FQDN1>"
android:targetActivity="<original activity name>"
android:label="<app label>"
android:icon="<app icon">
>
<intent-filter>
<!--TODO: Add this filter, if you want to support sharing images into your app-->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</intent-filter>
</activity-alias>
<activity-alias
android:name="<FQDN2>"
android:targetActivity="<original activity name>"
android:label="<app label>"
android:icon="<app icon">
>
<intent-filter>
<!--TODO: Add this filter, if you want to support sharing images into your app-->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</intent-filter>
</activity-alias>
copied to clipboard
Please note the android:name
in the <activity-alias>
it is used to define multiple different intents, it needs to be a Fully Qualified Domain Name
On the dart side
// For sharing images coming from outside the app while the app is in the memory
_intentDataStreamSubscription =
ReceiveSharingIntent.getMediaStream().listen((List<SharedMediaFile> value) {
copied to clipboard
this has been changed to
// For sharing images coming from outside the app while the app is in the memory
_intentDataStreamSubscription =
ReceiveSharingIntent.getMediaStream("<FQDN alias>").listen((List<SharedMediaFile> value) {
copied to clipboard
Similarly
ReceiveSharingIntent.getInitialMedia().then((List<SharedMediaFile> value) {
setState(() {
_sharedFiles = value;
});
});
copied to clipboard
has been modified to
ReceiveSharingIntent.getInitialMedia("<FQDN alias>").then((List<SharedMediaFile> value) {
setState(() {
_sharedFiles = value;
});
});
copied to clipboard
As this is only implemented on the Android side, you might need to wrap it in a Platform.isAndroid