user1017724
user1017724

Reputation: 55

Android. Opening a contact in through intent using contact_id or contact_name

I am using ContactsContract API in Android to get the list of contacts. The is working fine.

Now I want that when I click on a name in that list an intent is generated that will open the contact in the android contact manager.

The following code crashes the app:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(ContactsContract.Contacts.CONTENT_URI + "/" + ContactsContract.Contacts._ID));

kindly help me out here with this intent

Upvotes: 5

Views: 5934

Answers (1)

Soham
Soham

Reputation: 4970

This should show the contacts 'card' in the android contact manager

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactID));
intent.setData(uri);
context.startActivity(intent);

Upvotes: 14

Related Questions