Android - displays information about specific contacts

In my application, when the user clicks the button, I want to open the contacts application and display certain contact information.

At that moment I have this:

Intent intent = new Intent(Intent.ACTION_VIEW, People.CONTENT_URI);
startActivity(intent);

Displays a contact application with all displayed contacts.

But how do I get it to display only one contact in accordance with the name or number of contacts?

This code works: (answer)

Uri contactUri = ContentUris.withAppendedId(People.CONTENT_URI, 23);

Intent intent = new Intent(Intent.ACTION_VIEW, contactUri);
startActivity(intent);
+3
source share
1 answer

Add the contact ID to the end of the URI.

For example, the contents: // contacts / people / 615

or People.CONTENT_URI + "/" + contactId

.

+2

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


All Articles