return;
}
- ArrayList<Uri> uriList = new ArrayList<Uri>();
+ StringBuilder uriListBuilder = new StringBuilder();
+ int index = 0;
for (;!cursor.isAfterLast(); cursor.moveToNext()) {
- uriList.add(Uri.withAppendedPath(
- Contacts.CONTENT_VCARD_URI,
- cursor.getString(0)));
+ if (index != 0)
+ uriListBuilder.append(':');
+ uriListBuilder.append(Uri.encode(cursor.getString(0)));
+ index++;
}
+ Uri uri = Uri.withAppendedPath(
+ Contacts.CONTENT_MULTI_VCARD_URI,
+ Uri.encode(uriListBuilder.toString()));
- final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
+ final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType(Contacts.CONTENT_VCARD_TYPE);
- intent.putExtra(Intent.EXTRA_STREAM, uriList);
+ intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
} finally {
cursor.close();
// Assume that VCardSourceDetector was able to detect the source.
}
String charset = detector.getEstimatedCharset();
- createdUri = doActuallyReadOneVCard(uri, mAccount,
+ doActuallyReadOneVCard(uri, mAccount,
charset, false, detector, mErrorFileNameList);
mProgressDialogForReadVCard.incrementProgressBy(1);
}
mNeedReview = false;
Log.v("importVCardActivity", "Prepare to review the imported contact");
- // get contact_id of this raw_contact
- final long rawContactId = ContentUris.parseId(createdUri);
- Uri contactUri = RawContacts.getContactLookupUri(getContentResolver(),
- ContentUris.withAppendedId(RawContacts.CONTENT_URI,
- rawContactId));
+ if (createdUri != null) {
+ // get contact_id of this raw_contact
+ final long rawContactId = ContentUris.parseId(createdUri);
+ Uri contactUri = RawContacts.getContactLookupUri(getContentResolver(),
+ ContentUris.withAppendedId(RawContacts.CONTENT_URI,
+ rawContactId));
- Intent viewIntent = new Intent(Intent.ACTION_VIEW, contactUri);
- startActivity(viewIntent);
+ Intent viewIntent = new Intent(Intent.ACTION_VIEW, contactUri);
+ startActivity(viewIntent);
+ }
}
} else {
StringBuilder builder = new StringBuilder();
} catch (VCardNestedException e) {
Log.e(LOG_TAG, "Never reach here.");
}
- return committer.getLastCreatedUri();
+ final ArrayList<Uri> createdUris = committer.getCreatedUris();
+ return (createdUris == null || createdUris.size() != 1) ? null : createdUris.get(0);
}
private boolean readOneVCardFile(Uri uri, String charset,