How to Show multiple image share options of our Application like facebook?
Asked Answered
R

1

6

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

Like facebook multiple icons are shown

Somebody please help me to show multiple icons of my application when a user try to share an image from their gallery.

Regimen answered 17/4, 2020 at 17:48 Comment(2)
Android Share Sheet - Check the section on adding custom targets and the receiving simple data from other apps.Kindig
To add icons and labels check this page out: developer.android.com/guide/topics/manifest/…Lavernelaverock
L
5

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 :)

Lavernelaverock answered 23/4, 2020 at 12:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.