At the moment I am searching for an easy and supported way of adding contacts in Android up from SDK level 7. (when some kind of data like the phone number is available) I looked at the default contact application and found "Intent.ACTION_INSERT_OR_EDIT" which is used for adding a new contact (or adding a number to a contact from the contact provider) from the dialer screen with the mime type "vnd.android.cursor.item/person". Now it would be nice to know how to find some documentation about the extras that should be added when using that action and if it is the correct way trying to support as much as possible handsets.
I'm looking forward reading your ideas. Thank you very much.
Regards.
As much of the Android documentation goes, the documentation for native intents is pretty slim, but the available extras are listed here: http://developer.android.com/reference/android/provider/ContactsContract.Intents.Insert.html
Here is an example:
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, "example@example.com");
startActivity(intent);
The code above should start an activity that lets you pick a contact to edit with the "example@example.com" inserted as a new email, or let you create a new contact with "example@example.com" inserted as the email.
来源:https://stackoverflow.com/questions/3520499/android-intent-action-action-insert-or-edit-should-it-be-used-for-adding-con