0
我有一個Nexus 6(Android 7.0)的奇怪問題,當通過intent添加新聯繫人時,Uri的結果與rawContacts不像往常一樣查找。當在Google設備上添加新聯繫人時出現不同結果(Nexus 6,Pixel)
這是我的意圖:
public static Intent getNewContactIntent() {
Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI);
intent.putExtra("finishActivityOnSaveCompleted", true);
return intent;
}
結果onActivityResult:
Uri contactUri = data.getData();
在Nexus 6(API 24)設備:
內容://com.android.contacts/raw_contacts/1376
雖然在其他設備上,包括的Nexus 6模擬器:
內容://com.android.contacts/contacts/lookup/2883i3c5a4b238cc57aad/1376
如何設法讓所有相同的結果Android設備包括谷歌的?
額外的信息:
這種怪異的行爲可以在像素被複制(安卓8)了。
與URI檢索的數據(.../raw_contacts/1376):
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
| column | value |
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
| sort_key | Maher1 |
| send_to_voicemail | 0 |
| pinned | 0 |
| display_name | Maher1 |
| metadata_dirty | 0 |
| phonebook_label_alt | M |
| phonebook_bucket | 13 |
| version | 7 |
| custom_ringtone | null |
| _id | 1376 |
| times_contacted | 0 |
| account_type_and_data_set | com.google |
| sync4 | null |
| dirty | 0 |
| sync2 | Rn48fTVSLi17ImA9XBZXEUUJQwI."" |
| contact_id | 1376 |
| raw_contact_is_user_profile | 0 |
| aggregation_mode | 0 |
| data_set | null |
| phonebook_label | M |
| account_type | com.google |
| sync3 | 2017-08-31T12:44:27.075Z |
| display_name_alt | Maher1 |
| phonetic_name | null |
| last_time_contacted | null |
| display_name_source | 40 |
| backup_id | 3c5a4b238cc57aad |
| phonebook_bucket_alt | 13 |
| sort_key_alt | Maher1 |
| starred | 0 |
| deleted | 0 |
| account_name | maher*********@gmail.com |
| sourceid | 3c5a4b238cc57aad |
| sync1 | https://www.google.com/m8/feeds/contacts/maher*********%40gmail.com/base2_property-android_linksto-gprofiles_highresphotos/3c5a4b238cc57aad |
| phonetic_name_style | 0 |
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
雖然這可能與預期的URI(... /聯繫人/查找/ 2883i3c5a4b238cc57aad/1376檢索數據):
+--------------------------------+-----------------------+
| column | value |
+--------------------------------+-----------------------+
| sort_key | Maher1 |
| photo_uri | null |
| send_to_voicemail | 0 |
| contact_status | null |
| contact_status_label | null |
| pinned | 0 |
| display_name | Maher1 |
| phonebook_label_alt | M |
| phonebook_bucket | 13 |
| contact_status_res_package | null |
| in_default_directory | 1 |
| photo_id | null |
| custom_ringtone | null |
| _id | 1376 |
| times_contacted | 0 |
| phonebook_label | M |
| lookup | 2883i3c5a4b238cc57aad |
| display_name_alt | Maher1 |
| phonetic_name | null |
| last_time_contacted | 0 |
| contact_last_updated_timestamp | 1504183466085 |
| has_phone_number | 0 |
| in_visible_group | 1 |
| photo_file_id | null |
| display_name_source | 40 |
| is_user_profile | 0 |
| contact_status_ts | null |
| sort_key_alt | Maher1 |
| phonebook_bucket_alt | 13 |
| contact_presence | null |
| starred | 0 |
| photo_thumb_uri | null |
| contact_status_icon | null |
| contact_chat_capability | null |
| name_raw_contact_id | 1376 |
| phonetic_name_style | 0 |
+--------------------------------+-----------------------+
沒有要求'ACTION_INSERT'返回具有特定結構的'Uri'。什麼*記錄*值是你無法用一個'Uri'獲得,你可以用另一個獲得? – CommonsWare
@CommonsWare它不是關於意圖我用startActivity ..我嘗試了很多其他..我剛剛在Android設備上獲得了不同的Uri onActivityResult Android7.0 + –
那麼,您也可能會從其他聯繫人應用中獲得不同的Uri值。畢竟,用戶能夠安裝其他應用程序來響應您的「ACTION_INSERT」請求。 – CommonsWare