Android Intent Action "ACTION_INSERT_OR_EDIT" - should it be used for adding contacts?
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.
精彩评论