android - 从联系人列表中选择联系人并为该联系人选择特定的电子邮件

标签 android android-intent contacts android-contacts intentfilter

我知道如果我创建这样的 Intent:

val contactPickerIntent = Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI)
        startActivityForResult(contactPickerIntent, request_code)

我将能够从我的联系人列表中选择一个联系人。

如果我这样设置 Intent :

val contactPickerIntent = Intent(Intent.ACTION_VIEW, ContactsContract.Contacts.CONTENT_URI)

我将能够进入选定的联系人详细信息(从联系人应用程序中),但我无法从中选择任何内容。

问题是我需要打开联系人的详细信息并选择其中一个电子邮件地址,以防他有多个,然后选择它。

有办法吗?

最佳答案

您可以将选择器从联系人选择器更改为电子邮件选择器:

Intent contacts = new Intent(Intent.ACTION_PICK, CommonDataKinds.Email.CONTENT_URI); // Note the Email!
startActivityForResult(contacts, PICK_CONTACTS);

参见:https://developer.android.com/guide/components/intents-common#Contacts

关于android - 从联系人列表中选择联系人并为该联系人选择特定的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54095903/

相关文章:

Android "no app can perform this action"通过 URL 但在手机上工作正常

java - 获取联系人错误 - 如何解决?

macos - 适用于 Mac OS X 10.11 的 CNContact

java - 升级React Native 0.61.5:Android停留在初始屏幕上

android - 如何将 OnClickListener 添加到 EditText 中的 Drawable?

Android - Intent.putExtra() 失败

android - 使用 ACTION_IMAGE_CAPTURE 以较低的分辨率打开 Android 相机

android - 使用安卓 :action to launch activity from settings

安卓弹出菜单

android - 我应该如何使用 alarmmanager 每天和中午 12 点运行服务