I am trying to replicate some of the types of OEM dialer behavior with respect to contact matching without much luck. In principle, I would like to fill out a list of potential contact matches, as the user enters numbers in the number that correspond to the entered record by phone number and name, as most phones do. For example, entering 323 in the dialer number will correspond to contacts that have 323 anywhere in NUMBER, for example, (323) 123-4567, as well as contacts with DISPLAY_NAME from Dad or Daffy, etc.
I know that ContactsContract.PhoneLookup.CONTENT_FILTER_URI is supposed to be used to match phone numbers while ignoring formatting (therefore, a request that uri against 5551234567 will return a contact whose number was saved as (555) 123-4567). The problem is that I cannot get this to work with partial numbers, so the query for 5551 will include the same result, even if I add selection arguments with a LIKE clause and wildcards. If I use any of the other URIs, the select argument with LIKE will return partial results, but formatting twists things so that 5551 does not match, only 555) 1. Can someone explain how I can get a partial match of numbers while ignoring formatting from one request? Other attempts to use multiple queries turned out to be too slow and do not offer the experience that I see on most phones (I noticed that in the Android browser on the Android device, contact matching is not performed, only search, so there is no help).
Secondly, I have a working solution for the name of some of the things, although I'm not sure if this is the best strategy. I was hoping to use ContactsContract.Contacts.CONTENT_FILTER_URI, as the docs say that this is how you should filter the results for sentences like your type, but again, that will only work for alpha searches with one partial name, while I need to translate 323 to search for partial matches for all combinations of the corresponding keyboard letters (dad, dae, daf, ead, eae, eaf, fad, etc.). Instead, I used ContactsContract.CommonDataKinds.Phone.CONTENT_URI with the selection arguments, using LIKE to match all possibilities, and then subsequent queries narrow the field based on the contact IDs returned from the previous query. Is there a way to use ContactsContract.Contacts.CONTENT_FILTER_URI for this type of mapping to a numeric pattern? I did not try to break it into several queries, but based on the delay, I experienced something similar to the partial match of numbers described above, I suspect that this will not work very well.
Any advice is greatly appreciated!
Thanks Scott