我正在編寫一個應用程序,我需要向用戶顯示一個聯繫人。我有電話號碼,我可以查詢以獲取聯繫詳情。像這樣:如何顯示設備的主要聯繫人查看器顯示與電話號碼的一個聯繫人
ContentResolver cr = context.getContentResolver();
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(phoneNumber));
Cursor cursor = cr.query(uri,
new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME}, null, null, null);
if (cursor == null) {
return null;
}
String contactName = phoneNumber;
if (cursor.moveToFirst()) {
contactName = cursor.getString(cursor
.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
}
但是我需要顯示設備的主要聯繫人查看器,我不知道如何?
像這樣:
這是所有記錄在這裏:https://developer.android.com/guide/components/intents-common.html在章節「聯繫人/人的應用程序」 –
@MarcinOrlowski感謝您的回覆。但不幸的是,我無法訪問您的鏈接,也沒有谷歌文件也在我的地區! – Beppe
令人印象深刻。我發佈了相關報價的回覆。 –