打开一个电子邮件客户端上点击一个按钮 [英] Opening an email client on clicking a button
问题描述
我设计一个应用程序中,我需要在点击一个按钮打开一个电子邮件客户端。电子邮件客户端应打开了pre定义的主题和到的地址。有没有办法实现这一点?请为我提供的解决方案和code例如,如果可能的...
I am designing an app in which i need to open an email client on clicking a button. The email client should be opened with a pre-defined subject and 'to' address. Is there a way to attain this? Please provide me the solution and a code example if possible...
推荐答案
是这样的:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "some@email.address" });
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, ""));
另外,你可以使用<一个href="https://github.com/yanchenko/droidparts/blob/master/droidparts/src/org/droidparts/util/intent/IntentFactory.java">IntentFactory.getSendEmailIntent(String邮寄地址,字符串mailCC, 字符串主题,CharSequence的身体,文件附件)。
Alternatively, you could use IntentFactory.getSendEmailIntent(String mailTo, String mailCC, String subject, CharSequence body, File attachment).
这篇关于打开一个电子邮件客户端上点击一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!