Search contact by phone number

后端 未结 2 1828
感动是毒
感动是毒 2020-11-28 07:26

In my app, user writes a phone number, and I want to find the contact name with that phone number?

I usually search the contacts like this:

Cursor          


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 08:12

    You should have a look at the recommended ContactsContract.PhoneLookup provider

    A table that represents the result of looking up a phone number, for example for caller ID. To perform a lookup you must append the number you want to find to CONTENT_FILTER_URI. This query is highly optimized.

    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
    resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
    

提交回复
热议问题