gpt4 book ai didi

Android Contacts Content Provider返回同一联系人的多个副本,联系人中没有重复的联系人

转载 作者:太空狗 更新时间:2023-10-29 15:03:15 24 4
gpt4 key购买 nike

public static String getContactName(Context context, String id, String address){

if(id==null){
if(address==null){
return null;
}else{
return PhoneNumberUtils.formatNumber(address);
}
}

Cursor cursor = context.getContentResolver().query(
ContactsContract.Data.CONTENT_URI,
null,
null,
null,
null);

if(cursor!=null){
try{
if(cursor.moveToFirst()){
do{
for(int i=0;i<cursor.getColumnCount();++i){
String columnName = cursor.getColumnName(i);
String columnText = cursor.getString(i);
Log.d(columnName, columnText==null ? "null":columnText);
}
Log.d("endline","***************************");
}while(cursor.moveToNext());


}else{
Log.d("cursor", "not greater than 0");
}
}finally{
cursor.close();
}
}

if(address != null){
return PhoneNumberUtils.formatNumber(address);
}

return "just testing shit";
}

所以我的问题是,当我退回所有联系人时,我得到了每个联系人的多份副本,但我不确定为什么,也不知道该怎么办。我在这里在线查看了我的联系人:https://www.google.com/contacts/#contacts

以及从我的手机中删除所有联系人并重新同步到谷歌联系人以确保没有重复。我不明白发生了什么,虽然我可能只是不知何故愚蠢。

这是输出的样子(截断为几个联系人)

第一个:

sort_key: James LaChance
photo_uri: null
status_label: null
status_ts: null
status_res_package: null
name_verified: 0
display_name: James LaChance
last_time_used: null
mimetype: vnd.android.cursor.item/photo
phonebook_label_alt: L
data6: null
version: 3
photo_id: null
data3: null
custom_ringtone: null
times_contacted: 0
account_type_and_data_set: com.google
dirty: 0
data7: null
data15: null
raw_contact_is_user_profile: 0
data_set: null
phonebook_label: J
data10: null
res_package: null
account_type: com.google
data11: null
display_name_alt: LaChance, James
lookup: 3448i1629e6890832873d
phonetic_name: null
last_time_contacted: 0
contact_last_updated_timestamp: 1403954657613
data13: null
in_visible_group: 1
chat_capability: null
data9: null
data_sync1: https://www.google.com/m8/feeds/photos/media/jmsmaupin1%40gmail.com/1629e6890832873d
sort_key_alt: LaChance, James
contact_presence: null
data_version: 0
phonetic_name_style: 0
name_raw_contact_id: 1
raw_contact_id: 1
send_to_voicemail: 0
data4: null
data12: null
contact_status: null
contact_status_label: null
pinned: 2147483647
status_icon: null
status: null
data1: null
phonebook_bucket: 10
data_sync2: null
contact_status_res_package: null
in_default_directory: 1
_id: 1
is_super_primary: 0
data5: null
contact_id: 8
data8: null
is_primary: 0
data_sync4: 0
has_phone_number: 1
display_name_source: 40
photo_file_id: null
data_sync3: null
data14: null
contact_status_ts: null
phonebook_bucket_alt: 12
mode: null
data2: null
group_sourceid: null
starred: 0
photo_thumb_uri: null
times_used: null
contact_status_icon: null
contact_chat_capability: null
sourceid: 1629e6890832873d

第二个:

sort_key: James LaChance
photo_uri: null
status_label: null
status_ts: null
status_res_package: null
name_verified: 0
display_name: James LaChance
last_time_used: null
mimetype: vnd.android.cursor.item/name
phonebook_label_alt: L
data6: null
version: 3
photo_id: null
data3: LaChance
custom_ringtone: null
times_contacted: 0
account_type_and_data_set: com.google
dirty: 0
data7: null
data15: null
raw_contact_is_user_profile: 0
data_set: null
phonebook_label: J
data10: 1
res_package: null
account_type: com.google
data11: 0
display_name_alt: LaChance, James
lookup: 3448i1629e6890832873d
phonetic_name: null
last_time_contacted: 0
contact_last_updated_timestamp: 1403954657613
data13: null
in_visible_group: 1
chat_capability: null
data9: null
data_sync1: null
sort_key_alt: LaChance, James
contact_presence: null
data_version: 0
phonetic_name_style: 0
name_raw_contact_id: 1
raw_contact_id: 1
send_to_voicemail: 0
data4: null
data12: null
contact_status: null
contact_status_label: null
pinned: 2147483647
status_icon: null
status: null
data1: James LaChance
phonebook_bucket: 10
data_sync2: null
contact_status_res_package: null
in_default_directory: 1
_id: 2
is_super_primary: 0
data5: null
contact_id: 8
data8: null
is_primary: 0
data_sync4: 10
has_phone_number: 1
display_name_source: 40
photo_file_id: null
data_sync3: null
data14: null
contact_status_ts: null
phonebook_bucket_alt: 12
mode: null
data2: James
group_sourceid: null
starred: 0
photo_thumb_uri: null
times_used: null
contact_status_icon: null
contact_chat_capability: null
sourceid: 1629e6890832873d

我是个白痴。问完这个问题后,我几乎立即找到了问题的答案。

引用:https://stackoverflow.com/a/3591323/2408279

基本上每个联系人类型都有一个引用 I.E.电子邮件、电话等(如果我没记错的话)

最佳答案

您应该改为查询 ContactsContract.CommonDataKinds.PhoneCONTENT_URI 表,如果有帮助请告诉我。

正如 pskink 所说,使用 DatabaseUtils.dumpCursor 来记录游标..更简单

关于Android Contacts Content Provider返回同一联系人的多个副本,联系人中没有重复的联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24466538/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com