I try to receive more than one contact in my app from the share feature in the Android Contact App but i receive only the first contact, I never receive action with ACTION_SEND_MULTIPLE.
I have used https://developer.android.com/training/sharing/receive as inspiration.
AndroidManifest :
<activity android:name=".ShareActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/x-vcard" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/x-vcard" />
</intent-filter>
</activity>
ShareActivity:
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
// My code always pass here because action is always equals to ACTION_SEND even with several contacts selectionned
if ("text/x-vcard".equals(type)) {
handleSendContact(intent);
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
if ("text/x-vcard".equals(type)) {
handleSendMultiContact(intent);
}
}
private void handleSendContact(Intent intent) {
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
// use uri to get lookupkey...
}
private void handleSendMultiContact(Intent intent) {
ArrayList<Uri> contactUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
for (Uri uri : contactUris) {
// use uri to get lookupkey...
}
}
Sharing a single contact, all work perfectly, but when I select two or more contact my received action still is ACTION_SEND and not ACTION_SEND_MULTIPLE and I receive only the first selected contact. My goal is to receive all contact selectionned in the Android Contact App.