如何显示设备主要联系人查看器以显示一个号码为 phone 的联系人

How can show device primary contact viewer to show ONE contact with phone number

我正在编写一个应用程序,我需要向用户显示一个联系人。我有 phone 号码,我可以查询以获取联系方式。像这样:

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));
    }

但我需要显示 DEVICE 主要联系人查看器,但我不知道怎么做?

像这样:

官方 Android 文档 Common Intents 章节 "Contacts/People App".

中记录了所有这些内容

编辑

But unfortunately I can not access to your link , nor google documents also in my area !!

以下是来自链接文档的引述:

查看联系人

要显示已知联系人的详细信息,请使用 ACTION_VIEW 操作并使用内容指定联系人:URI 作为意图数据。

最初检索联系人 URI 的方法主要有两种:

  • 使用上一节中显示的 ACTION_PICK 返回的联系人 URI(此方法不需要任何应用程序权限)。
  • 直接访问所有联系人列表,如检索联系人列表中所述(此方法需要 READ_CONTACTS 权限)。

示例:

public void viewContact(Uri contactUri) {
    Intent intent = new Intent(Intent.ACTION_VIEW, contactUri);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

编辑现有联系人

要编辑已知联系人,请使用 ACTION_EDIT 操作,指定具有内容的联系人:URI 作为意图数据,并在 ContactsContract.Intents.Insert 中常量指定的附加信息中包含任何已知联系人信息.

最初检索联系人 URI 的方法主要有两种:

  • 使用上一节中显示的 ACTION_PICK 返回的联系人 URI(此方法不需要任何应用程序权限)。

  • 直接访问所有联系人列表,如检索联系人列表中所述(此方法需要 READ_CONTACTS 权限)。

注意:附加项 - ContactsContract.Intents.Insert 中定义的一项或多项附加项,以便您可以填充联系方式的字段。

public void editContact(Uri contactUri, String email) {
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setData(contactUri);
    intent.putExtra(Intents.Insert.EMAIL, email);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

有关如何编辑联系人的详细信息,请阅读 Modifying Contacts Using Intents