发送邮件:Intent.EXTRA_EMAIL 不起作用

Tes*_*est 3 email android-intent

我没有收到任何错误,但不会显示邮件地址!它保持空白

public void Send_Mail(View view) {
        String txt_context = "My comment about the App : \n The App is good but does not support v3";
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setData(Uri.parse("mailto:"));
        intent.setType("message/rfc822"); // 
        intent.putExtra(Intent.EXTRA_EMAIL,"receiver@gmail.com"); // **this will not displayed** """
        intent.putExtra(Intent.EXTRA_SUBJECT,"Comment about the APP");
        intent.putExtra(Intent.EXTRA_TEXT,txt_context);
        startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

Ese*_*far 6

我知道这篇文章很旧,但我遇到了同样的问题,我找到了解决方案(在官方文档中):

正如所解释的,Intent.EXTRA_EMAIL是:

一个 String[] 保存应该发送到的电子邮件地址。

因此,要解决您的问题,而不是:

intent.putExtra(Intent.EXTRA_EMAIL,"receiver@gmail.com");
Run Code Online (Sandbox Code Playgroud)

做:

intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"receiver@gmail.com"});
Run Code Online (Sandbox Code Playgroud)