Android Intent Action “ACTION_INSERT_OR_EDIT” - should it be used for adding contacts?

后端 未结 1 570
不知归路
不知归路 2021-02-03 16:26

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 looke

相关标签:
1条回答
  • 2021-02-03 17:04

    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.

    0 讨论(0)
提交回复
热议问题