I am creating a social media application in which user can share images, videos, audios etc. I am successful in receiving the medias that shares from third party application by adding the below code in manifest file.
<activity
android:name=".activity.SendToActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
Now I want to show multiple icons of my application when a user try to share an image from their gallery like facebook(set as profile pic) to upload profile image directly. Please see the screenshot
Somebody please help me to show multiple icons of my application when a user try to share an image from their gallery.
To provide custom icons and labels on a picker you need to add parameters to the intent filter on the manifest. By default it uses the parent's icon and label.
You can override those as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter
android:icon="@drawable/ic_profile_icon" <!-- Custom icon -->
android:label="Set as profile"> <!-- Custom label -->
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter
android:icon="@drawable/ic_story_icon" <!-- Custom icon -->
android:label="Share as story"> <!-- Custom label -->
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
</manifest>
Please note that this is a sample app that holds no logic or value.
Hope it helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With