3

I can create new contact with Intent by passing info as extra data with putExtra, is it possible to create Intent with info and if contact is already in phonebook it will be update with new info?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user505160
  • 1,176
  • 8
  • 25
  • 44

2 Answers2

12

Actually you can use intents to create new contacts with ContactsContract and it's not deprecated.

http://developer.android.com/reference/android/provider/ContactsContract.Intents.Insert.html

example that works for me:

Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT);
i.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
i.putExtra(Insert.NAME, "TESTTEST");
i.putExtra(Insert.PHONE, "209384");
startActivity(i);
Juliet
  • 1,040
  • 3
  • 11
  • 18
1

Using Intents to create new contacts is deprecated since Android 2.0. Use ContactsContract.

Here are the docs and an example.

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154