I'm trying to lockup what contact belongs to a specific number. I'm
sending sms from one emulator instance to another (ie. 5554 to 5556
for example) and have entered contacts with those numbers. But when
running the code below my cursor doesn't return anything. The
filtering seems like it's not working, or I'm doing something wrong?

private String getContactNumber(String number) {

    String[] projection = new String[] {
                Contacts.Phones.DISPLAY_NAME,
                Contacts.Phones.NUMBER};

    Uri contactUri = Uri.withAppendedPath
(Contacts.Phones.CONTENT_FILTER_URL, Uri.encode(number));
    Cursor c = getContentResolver().query(contactUri, projection,
null, null, null);

    if (c.moveToFirst()) {
          String name = c.getString(c.getColumnIndex
(Contacts.Phones.DISPLAY_NAME));
          Log.d("Name", name);
          return name;

        }else{
                Log.d("GetContact", "Not a contact");
        }
        return number;
}


Any tips, hints would be much appreciated! Thank you in advance

Best Regards
Sime

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to