android 唤起系统分享文件或发送邮件(附件)

代码如下:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
context.startActivity(Intent.createChooser(intent, "分享一下"));
兼容问题参考:
https://www.jianshu.com/p/9520161ffb05  
https://blog.csdn.net/zhizuyiwang/article/details/51547403
发布了513 篇原创文章 · 获赞 2668 · 访问量 1311万+

猜你喜欢

转载自blog.csdn.net/jdsjlzx/article/details/104361633