Selecting a specific contact

Post your questions and help other users.

Moderator: Martin

Post Reply
stevek
Posts: 9
Joined: 26 Aug 2014 07:32

Selecting a specific contact

Post by stevek » 02 Sep 2014 05:18

Hi all,

I'm trying to find a way to access a specific contacts details by inputting the contacts name.

So far I have been able to access the contacts database, with the result that the contacts name that I am searching for appears in a search field at the top of the page and a list of all contacts with that name to be listed below. However, to access that contacts details (phone number, email, etc), I still have to manually click on the contacts name within the list.

The following is the activity that I'm using to query the customer database and which results in a display of the contact name being queried and a list of matching names:


Start Activity
Action: android.intent.action.SEARCH
Data URI: content://com.android.contacts/contacts
Extras: putString("query", "John");



As mentioned, the above successfully locates the contact ("John") but requires me to click on the found contact's name in order to access additional contact details.

Ideally, I just want to
--> input a contact name
and transparently (with no intermediate screens, clicks, etc)
<-- output the contact's phone number, email, etc

Is there any way of modifying the above activity (perhaps with a getString("phone number"), getString("email"), etc ? ) so that I can bypass the need to click on the contact listing first ?

Thanks,

Steve

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Selecting a specific contact

Post by Martin » 03 Sep 2014 17:28

Hi,

I'm not aware of an activity that allows to query all contact details without user interaction.
You could use an action Query Content Provider to read the contacts database on your own, but that's quite a complicated thing to do (see http://developer.android.com/guide/topi ... vider.html).
The action contains two basic examples to access some contact information by phone number.

Regards,
Martin

Post Reply