I am making an app that displays a list of people in a listview. When tapped, the app should transition to another screen displaying the contact details of that person loaded from a Person object i have retrieved from the DB. My question is how to display these details. In iOS, there was a ABUnknownPersonViewController that would mimic the native iOS addressbook entry to let me display the contact details in a clean and easy way. Is there anything similar for android that would let me use the People app's view or api to basically create and display a record exactly as android displays in its own People app?
2 Answers
your exact answer is contained here:
The method described in the above link opens native contacts app and lets the user pick a contact. Then onActivityResult() comes into picture, here you can process the contact as per your requirement.
If you want to customize the look and feel you need to check here
You can retrieve the list and customize the UI.
If you just want to display a single contact's details. you can use this code. (contactId is the contactId of the contact that user picked)
Intent contactIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_URI,
String.valueOf(contactId));
contactIntent.setData(uri);
startActivity(contactIntent);
Hope this helps.
-
I think you misunderstood the question... I do not want to display the phone's contacts to the user. The user picks a name from a list of names i display and a contact card for that name is display within the app. The details of this contact card come from my db. It has nothing to do with the phone or the contacts in the phone – John Baum May 23 '13 at 19:04
-
you need to create a custom layout say a listview with checkboxes and then populate the lsitview with items form database. When check box is checked retrieve the items from the list and do what you want. Is that what you are looking for?? – Raghunandan May 23 '13 at 19:06
-
If that is the case then I suggest you open the second link. It shows how you can get a list of all contacts. You can display just the contact names in a list view. In the onItemSelectedListener() you can get the contactID and use that to open a particular contact detail page. Wait I will update my answer. – drulabs May 23 '13 at 19:07
-
added code to open contact details screen. Check the above answer again. – drulabs May 23 '13 at 19:13
-
The contact details are NOT coming from android's People application. They are from my db. i just needed to know if i can display my OWN data using the same contact detail page style as Android's people app. Apparently there is no way to do so... – John Baum May 23 '13 at 19:21
No. You can look through the AOSP and see if the contacts app was released as open source, and if so use it. But remember that the contact app on all phones isn't the same, Samsung for example uses several different apps of their own. And some people download their own contact apps. So its impossible to have the native feel for everyone, unless you launch the contact app via an intent.

- 90,003
- 9
- 87
- 127