I try to make "type-to" filter in the my dialer. When I tap a digit, there must be a list (ListView) of supposed contacts (all of them have a number containing a part from my dialer TextView). For example, if I tap 555, there must be presented contacts with such numbers:
555890856
555789734
895550123
1st attempt:
2nd attempt:
In both attempts cursor count is always 0, despite I dial the phone number of real contact.
Is it possible to filter contacts by this criteria, using Android uris? Or there is no way but "get all contacts, iterate over them and check their numbers"?
555890856
555789734
895550123
1st attempt:
Code:
String phoneNumberPart = //this is the part of phone number. Only part!
final Uri baseUri = ContactsContract.Contacts.CONTENT_FILTER_URI;
final Uri uri = Uri.withAppendedPath(baseUri, Uri.encode(phoneNumberPart));
final String[] projection = CONTACTS_PROJECTION; //_ID, DISPLAY_NAME, LOOKUP_KEY
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
Code:
String phoneNumberPart = //this is the part of phone number. Only part!
final Uri baseUri = ContactsContract.PhoneLookup.CONTENT_FILTER_URI;
final Uri uri = Uri.withAppendedPath(baseUri, phoneNumberPart);
final String[] projection = CONTACTS_PROJECTION; //_ID, DISPLAY_NAME, LOOKUP_KEY
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
Is it possible to filter contacts by this criteria, using Android uris? Or there is no way but "get all contacts, iterate over them and check their numbers"?

