Search code examples
androidandroid-intentandroid-sharing

How to filter specific apps for ACTION_PICK intent and add cancel option


I want to filter specific app for ACTION_PICK and add remove photo option.

I can do filter specific app but i can not add remove photo option .

i want to default choose app dialog like whatsapp choose profile photo.

Whatsapp did it.

You can find screenshot below.

Thank you. enter image description here


Solution

  • You must create Activity and register this activity in AndroidManifest.xml

    AndroidManifest.xml

    <activity android:name=".GiveUpActivity"
            android:label="@string/give_up"
            android:icon="@drawable/ic_cancel">
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
    
                <data android:mimeType="image/*"/>
                <data android:mimeType="text/plain" />
            </intent-filter>
    </activity>
    

    And you create intent with your mimeType and startActivityForResult.

    After if user select Remove in choose dialog. You handle in onCreate method your GiveUpActivity.

    Thanks,