Email Intent not showing the chooser

2019-01-27 04:18发布

I'm using the following to initiate the sending of an email:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc882"); 
i.putExtra(Intent.EXTRA_EMAIL, new String[]{s});
startActivity(Intent.createChooser(i, "Send mail..."));

The problem that I'm having is that (on my phone) it pulls up Gmail's Compose window instead of allowing me to choose which email client I'd like to send the message with.

Am I doing this wrong, or does the default email client just not respond to email send intents?

2条回答
The star\"
2楼-- · 2019-01-27 04:38

It might not respond to message/rfc882 Intents. Try text/plain instead, if you can, as I'm pretty sure that works.

查看更多
别忘想泡老子
3楼-- · 2019-01-27 04:42

It's a common misconception to use text/plain. This will trigger any application that can handle plain text files without any context, including Google Drive, Dropbox, Evernote and Skype.

Instead use a ACTION_SENDTO, providing the mailto: Uri:

intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
startActivity(intent);
查看更多
登录 后发表回答