Android Opening a contact through intent using contact_id or contact_name

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

Now I want that when I click on a name in this list, an intent is created 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 here with this intention

+4
source share
1 answer

This should show the contact map 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); 
+12
source

Source: https://habr.com/ru/post/1400356/


All Articles