Android phone 多次查找 (PhoneLookup.CONTENT_FILTER_URI) returns 同一个联系人

Android phone lookup (PhoneLookup.CONTENT_FILTER_URI) returns the same contact multiple times

我正在使用 phone 号码查找联系人 here

Uri lookupUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(givenNumber));

final Account availableAccounts[] = AccountManager.get(context).getAccountsByType(Constants.ACCOUNT_TYPE);
Uri rawContactUri = ContactsContract.RawContacts.CONTENT_URI;

Cursor phoneContact = context.getContentResolver().query(
    lookupUri
    , null //new String[]{ContactsContract.PhoneLookup._ID, ContactsContract.PhoneLookup.DISPLAY_NAME}
    ,null,null, null);

DatabaseUtils.dumpCursor(phoneContact);

while (phoneContact.moveToNext()) {
    long contactID = phoneContact.getLong(phoneContact.getColumnIndex(ContactsContract.PhoneLookup._ID));            
}
phoneContact.close();

出于调试目的,投影设置为空。 从 DatabaseUtils.dumpCursor(phoneContact);:

的结果可以看出,我多次收到相同的联系人
>>>>> Dumping cursor android.content.ContentResolver$CursorWrapperInner@1517c824
0 {
number=+00001122334
photo_uri=content://com.android.contacts/display_photo/6
send_to_voicemail=0
lookup=32i415560988b4aed0e.32i636352790bf3a3a6.3789r869-2D4531433931.3746i15
display_name=John Doe
last_time_contacted=1425383680707
has_phone_number=1
in_visible_group=1
photo_file_id=6
label=null
starred=0
normalized_number=+00001122334
photo_thumb_uri=content://com.android.contacts/contacts/212/photo
photo_id=1427
in_default_directory=1
custom_ringtone=null
_id=212
type=2
times_contacted=44
}
1 {
number=0001122334
photo_uri=content://com.android.contacts/display_photo/6
send_to_voicemail=0
lookup=32i415560988b4aed0e.32i636352790bf3a3a6.3789r869-2D4531433931.3746i15
display_name=John Doe
last_time_contacted=1425383680707
has_phone_number=1
in_visible_group=1
photo_file_id=6
label=null
starred=0
normalized_number=+27001122334
photo_thumb_uri=content://com.android.contacts/contacts/212/photo
photo_id=1427
in_default_directory=1
custom_ringtone=null
_id=212
type=2
times_contacted=44
}
2 {
number=0001122334
photo_uri=content://com.android.contacts/display_photo/6
send_to_voicemail=0
lookup=32i415560988b4aed0e.32i636352790bf3a3a6.3789r869-2D4531433931.3746i15
display_name=John Doe
last_time_contacted=1425383680707
has_phone_number=1
in_visible_group=1
photo_file_id=6
label=null
starred=0
normalized_number=+27001122334
photo_thumb_uri=content://com.android.contacts/contacts/212/photo
photo_id=1427
in_default_directory=1
custom_ringtone=null
_id=212
type=2
times_contacted=44
}
<<<<<

注意:出于隐私原因,我已经替换了 phone 号码。联系人之间唯一的区别是第一个是国际格式的号码(+00),而其余的是本地格式。

如果有人可以阐明这种行为,这个问题与我的相同,但细节较少 here, but it is also unanswered. Similar questions consist of people not checking on mime_types, for example

谢谢。

在这里查看答案: .

基本上,您可以使用 CommonDataKinds.Phone.CONTENT_FILTER_URI 而不是 PhoneLookup.CONTENT_FILTER_URI 来获得单个结果。