Problem:
I'm seeing my own app in the device's app chooser when sharing an image from within my app.
I'm working on a photo app that will allow users to share their edited images using an Intent.ACTION_SEND with the device's application chooser by starting the chooser activity from an Intent.createChooser. Within my AndroidManifest.xml file I have declared a provider.
I'm also allowing other applications to launch my application by sharing images and selecting my app in the device's chooser activity. Within the AndroidManifest.xml the activity has an intent-filter with android.intent.action.SEND as the action.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testcom.mypicapp">
<application
android:allowBackup="true"
android:icon="@mipmap/app_icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/app_icon"
android:supportsRtl="true"
android:theme="@style/Theme.MyPicApp">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.testcom.mypicapp.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"
/>
</provider>
<activity
android:name=".MyPicAppActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
</application>
</manifest>
Here's the code I'm using to share the edited image:
Intent shareIntent = new Intent();
shareIntent.setAction( Intent.ACTION_SEND );
shareIntent.putExtra( Intent.EXTRA_STREAM, shareUri );
shareIntent.setType( "image/png" );
Intent chooser = Intent.createChooser( shareIntent, "Share My Pic App Image" );
startActivityForResult( chooser, SHARE_RESPONSE_CODE );
Question:
So how would I prevent my app showing in the application chooser that my application started, while being included in other app's application chooser? Is there a way to exclude my application, perhaps adding an extra in the intent to start the application chooser?
Any help is appreciated. Thanks