android-intent 使用android intent进行电子邮件共享[仅文本]
示例
这将触发本地电子邮件客户端共享文本。
参数:通过电子邮件发送至地址,主题,正文。
代码示例:
您可以在任何需要的地方调用该函数(主要在点击监听器中),如下所示
通话功能
shareEmail("sample@gmail.com", "Email sharing example", "This the sample demo to share the sample text through native email clients using Android Intent");全局功能
public void shareEmail(String to_email_id, String subject, String body) {
//此功能将打开设备中安装的电子邮件客户端,以通过意图从您自己的应用程序共享。
Intent sharingIntent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
sharingIntent.setType("message/rfc822");
/* All the below fields are optional. If not given simply opens the email client */
//到电子邮件ID
sharingIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{to_email_id});
//分享时需要出现的主题
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
//邮件正文共享。
sharingIntent.putExtra(Intent.EXTRA_TEXT, body);
(mContext).startActivity(Intent.createChooser(sharingIntent, "Share content through email")
);
} //shareEmail
热门推荐
7 简短的二胎祝福语
10 简短霸气女儿生日 祝福语
11 祝福语高考小众诗句简短
12 元旦祝福语20秒简短
13 老师过年祝福语大全 简短
14 一生祝福语简短
15 产检祝福语简短霸气
16 朋友店开张祝福语简短
17 生日爱情祝福语大全简短
18 朋友女儿生日祝福语 简短