sinkuri256 / android-scripting

Automatically exported from code.google.com/p/android-scripting
0 stars 0 forks source link

Add a method to look up a contact by phone number #555

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I created an app to read text messages out loud, but I can't find a way to 
figure out which contact the phone number belongs to.  Well, except by calling 
contactsGetAll or whatever and searching through all 800 contacts myself.

* What is the expected output? What do you see instead?
The method should take a string, and return the contact information.  A second 
optional argument could be the list of attributes you're interested in.

Original issue reported on code.google.com by ryanshil...@gmail.com on 18 Jul 2011 at 2:32

GoogleCodeExporter commented 9 years ago
This is just a matter of using the right query:

Example code (python):
-------------
import android,urllib
droid = android.Android()
phone="your phone number"
uri="content://com.android.contacts/phone_lookup/"+urllib.quote(phone)
print droid.queryContent(uri).result
--------

Original comment by rjmatthews62 on 21 Aug 2011 at 12:05