Reputation: 343
I add informations to a new contact via intent in this way:
Intent intent = new Intent(Intents.Insert.ACTION);
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
//...
intent.putExtra(Intents.Insert.NAME,"name");
intent.putExtra(ContactsContract.Intents.Insert.COMPANY,"company");
//...
startActivity(intent);
It works fine, but I want to add also website info. What's the "keyword" to use in "putExtra" for this?
Upvotes: 1
Views: 678
Reputation: 2860
Here a complete example in Kotlin:
val intent = Intent(Intent.ACTION_INSERT)
intent.type = ContactsContract.Contacts.CONTENT_TYPE
intent.putExtra(ContactsContract.Intents.Insert.NAME, "Your name")
val data = ArrayList<ContentValues>()
val row = ContentValues()
row.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE);
row.put(ContactsContract.CommonDataKinds.Website.TYPE, ContactsContract.CommonDataKinds.Website.TYPE_CUSTOM);
row.put(ContactsContract.CommonDataKinds.Website.URL, "www.your.site")
data.add(row)
intent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, data);
startActivity(intent)
Tested and working on Android Studio EEL.
Upvotes: 1
Reputation: 3993
Documentation: ContactsContract.Intents.Insert
You can use DATA
The extra field that allows the client to supply multiple rows of arbitrary data for a single contact created using the ACTION_INSERT or edited using ACTION_EDIT. It is an ArrayList of ContentValues, one per data row. Supplying this extra is similar to inserting multiple rows into the ContactsContract.Contacts.Data table, except the user gets a chance to see and edit them before saving. Each ContentValues object must have a value for MIMETYPE. If supplied values are not visible in the editor UI, they will be dropped. Duplicate data will dropped. Some fields like Email.TYPE may be automatically adjusted to comply with the constraints of the specific account type. For example, an Exchange contact can only have one phone numbers of type Home, so the contact editor may choose a different type for this phone number to avoid dropping the valuable part of the row, which is the phone number.
usage:
intent.putParcelableArrayListExtra(Insert.DATA, data);
Upvotes: 1