How do I create an intent to launch any e-mail app?

别说谁变了你拦得住时间么 提交于 2019-12-04 14:17:33

Does anyone know how to accomplish this?

There is no such Intent -- you can tell this by examining the manifest for the Email application.

The only thing you can do is build yourself a list of email clients you wish to link to and use the PackageManager code you show above for each.

Fred

Can a mailto URL be used in some fashion to accomplish this? --Edit-- I was able to accomplish this using the following code sample:

mt = MailTo.parse("mailto:yourname@gmail.com");
sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{mt.getTo()});
sendIntent.putExtra(Intent.EXTRA_TEXT, "");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Enter a subject");
sendIntent.setType("message/rfc822");
startActivity(Intent.createChooser(sendIntent, "Send a Message:"));

Another approach could be Intent.createChooser(); and let the user to choose the right application.

BTW The list could contain not only email applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!