Search code examples
androidsharemanifestintentfilter

How to give multiple share options for an app in google photos?


I am trying to provide two share option for image sharing, so i have two activity which can accept image type.It works well everywhere other than Google photos. If i comment out one of them from manifest then it works fine , but if i keep both then only one will show up when i click on share button and clicking on it will take me to the other activity, not the one it is associated with.

This problem only occurs in Google photos app and nowhere else.

<activity
        android:name="mobi.abc.xyz.NewPostActivity">

        <intent-filter android:label="Socials">
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.SEND_MULTIPLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.PICK" />

            <data android:mimeType="text/plain" />
            <data android:mimeType="application/*" />
            <data android:mimeType="image/*" />
            <data android:mimeType="video/*" />
        </intent-filter>
    </activity>

    <activity
        android:name="mobi.abc.xyz.EditActivity">

        <intent-filter android:label="Share Image to Edit">
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.SEND_MULTIPLE" />

            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.PICK" />
            <data android:mimeType="image/*" />
        </intent-filter>
    </activity>

Solution

  • Hi I came here to write the same thing which @kolboc mentioned i.e google photos make filtrations because twitter and Instagram are famous apps and may be google giving them a priority and hence displaying both instances of sharing for those apps but I was wrong...

    I found a solution to fix this ...

    So the reason it is occurring is you are mentioning labels in the hardcoded string. So replace those with some String file names like this ...

    <activity
            android:name="mobi.abc.xyz.NewPostActivity">
    
            <intent-filter android:label="@string/socials">
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <action android:name="android.intent.action.PICK" />
    
                <data android:mimeType="text/plain" />
                <data android:mimeType="application/*" />
                <data android:mimeType="image/*" />
                <data android:mimeType="video/*" />
            </intent-filter>
        </activity>
    
        <activity
            android:name="mobi.abc.xyz.EditActivity">
    
            <intent-filter android:label="@string/share_image_to_edit">
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />
    
                <category android:name="android.intent.category.DEFAULT" />
                <action android:name="android.intent.action.PICK" />
                <data android:mimeType="image/*" />
            </intent-filter>
        </activity>
    

    I don't know what kind of code they are using to label those but this was the problem that was causing this ... so just replace those it will work ...

    Demo Image

    Demo

    I have marked the app instance by red but as you notice I have no control over the position of occurrences of my app instances. Google photos arrange them like this. Again I am not sure why? ... but as soon as I clicked on one of sharing intent of my app in the next attempt it shown my app instances like this ...

    After Clicking

    I think again google is being smart here ... I think they are making list based on last used priority...

    Happy Coding.. :)