Note that there are some explanatory texts on larger screens.

plurals
  1. POQuerying Contacts with Partial Data
    primarykey
    data
    text
    <p>I've been trying to replicate some of the OEM dialer app behaviors regarding contact matching without much luck. Basically, I'd like to populate a list of potential contact matches as the user types numbers into the dialer that match the typed entry against the phone number and the name, as most phones do. For instance, typing 323 into the dialer would match contacts that have 323 anywhere in the NUMBER, such as (323)123-4567 as well as contacts with DISPLAY_NAME of Dad or Daffy, etc.</p> <p>I know that ContactsContract.PhoneLookup.CONTENT_FILTER_URI is supposed to be used to match phone numbers while ignoring formatting (so querying that uri against 5551234567 would return a contact whose number was stored as (555)123-4567). The problem is that I cannot get this to work with partial numbers, so that querying against 5551 would include the same result, even if I add selection args with a LIKE clause and wildcards. If I use any of the other URIs, the selection arg with LIKE will return partial results, but the formatting screws things up so that 5551 would not match, only 555)1 does. <strong>Can anybody explain how I might get a partial number match while ignoring formatting from a single query?</strong> Other attempts to use multiple queries have proved to be too slow and not offer the experience I see on most phones (I have noticed that the stock dialer in the Android source does not do the contact matching, only search, so no help there).</p> <p>Secondly, for the name part of things, I have a working solution, although I'm not sure it is the best strategy. I had hoped to use ContactsContract.Contacts.CONTENT_FILTER_URI, as the docs say this is how you should filter results for as-you-type suggestions, but again that would only work for an alpha search of a single partial name, while I need to translate 323 to search against partial matches for all combinations of the associated keypad letters (dad, dae, daf, ead, eae, eaf, fad, etc). I have instead used ContactsContract.CommonDataKinds.Phone.CONTENT_URI with selection args using LIKE to match against all possibilities, and then subsequent requests narrow the field based on contact IDs returned from the previous request. <strong>Is there a way to leverage ContactsContract.Contacts.CONTENT_FILTER_URI for this type of numeric pattern matching?</strong> I haven't tried breaking it down to multiple requests, but based on the latency I experienced trying something similar for partial number matching described above, I suspect it would not work very well.</p> <p>Any advice is much appreciated!</p> <p>Thanks, Scott</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload