Android打开邮箱显示建议的联系人

时间:2017-10-03 08:17:04

标签: android android-intent

在Android上,我实现了一个按钮以打开邮箱。单击此按钮时,弹出窗口会显示已安装的邮箱,但我看到建议的联系人。

有人知道如何删除此联系人?我想只看邮箱。

屏幕截图:

enter image description here

我的意图配置代码:

    // basic information
    String body = "hello"
    String recipientsList[] = { "hello@hello.com"};
    String subject = "subject"

    // configure intent to open maibox
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
    emailIntent.setType("message/rfc822");

    // configure new email
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipientsList);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
    emailIntent.setData(Uri.parse("mailto:"));

谢谢!

编辑 - 已解决:只需使用以下代码启动邮箱解决问题(但修改选择器的外观)

startActivity(emailIntent);

1 个答案:

答案 0 :(得分:2)

尝试以下

 String subject = "Feedback";
            String bodyText = "Enter text email";
            String mailto = "mailto:bob@example.org" +
                    "?cc=" + "" +
                    "&subject=" + Uri.encode(subject) +
                    "&body=" + Uri.encode(bodyText);

            Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
            emailIntent.setData(Uri.parse(mailto));

            try {
                startActivity(emailIntent);
            } catch (ActivityNotFoundException e) {
                //TODO: Handle case where no email app is available
            }

输出:

enter image description here