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