Like Instagram, I need to display multiple choices when a user wants to share a picture to my app. My manifest code is:
<activity android:name="com.myapp.android.ui.MainActivity"
android:screenOrientation="portrait">
<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/*" />
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter android:label="@string/intent_chat">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter android:label="@string/intent_chat">
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
</activity>
This properly display 2 options to the user when trying to share an image or video. One labeled with the application name, the other with @string/intent_chat. The problem is that I can't figure out how to know which one the user chose when handling the incoming Intent. I tried using the label, but can't figure out how to access it from the Intent.
The other option would be to keep a single intent-filter and in my activity display a dialog to have the user specify what he wants to do. However, that implies an additional click, which I would like to avoid.