Looking up a contact by a phone number
I am getting contact details for a given phone number using the following code:
Uri uri = Uri.withAppendedPath(PhoneLookup.CONT开发者_开发技巧ENT_FILTER_URI, Uri.encode(phoneNum));
Cursor cursor = context.getContentResolver().query(uri,null,null,null,null);
There is a case though when the cursor contains 3 records with the same phone number and display name.
Can you please suggest an explanation or possible reason for that?
Thanks a lot.
Are you certain that you don't have the same number entered for 3 different contacts or 3 different contact methods? You can have multiple contacts with the same numbers and manually merge them in the contacts app.
The URI you are building is a query for the contacts content provider so in the case above it is possible to return more than one contact for a given number.
精彩评论