Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 366
user1017724 Avatar asked Mar 08 '12 10:03

user1017724


1 Answers

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);
like image 74
Soham Avatar answered Oct 16 '22 10:10

Soham