Rishi
Rishi

Reputation: 3539

Open add contact activity android sdk 2.1 and above

i am using the following code to open android defaults add contact activity to add contact in phone.

          Intent intentInsert = new Intent(Contacts.Intents.Insert.ACTION);
          intentInsert.setData(People.CONTENT_URI);
          startActivity(intentInsert);

But its showing deprecated when using in android sdk 2.1 and above. how to show add contact activity in new contacts contract api.

Thanks

Upvotes: 2

Views: 1904

Answers (2)

Balban
Balban

Reputation: 736

yes above method got deprecated after 2.1 or above try to use

intentInsert.setData(ContactsContract.CONTENT_URI);

for sdk 2.1 or above

Upvotes: 1

Rasel
Rasel

Reputation: 15477

try this

 Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT);
                        i.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
                        i.putExtra(Insert.NAME,"Name");
                        i.putExtra(Insert.PHONE,"Number");
                        startActivity(i);

Upvotes: 4

Related Questions