这是一个简单的分享到邮箱的实现,你可以附上自己的图片。
- //cacheDir是你所要共享的文件对象所在的目录
- //你可以用自己的文件对象覆盖File f
- File cacheDir = new File(android.os.Environment.getExternalStorageDirectory(), getString(getApplicationInfo().labelRes));
- File f = new File(cacheDir, "p_w_picpath_name.jpg");
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setType("p_w_picpath/jpeg");
- intent.putExtra(Intent.EXTRA_TEXT, "Email body over here");
- intent.putExtra(Intent.EXTRA_SUBJECT, "Email subject over here");
- intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
- startActivity(Intent.createChooser(intent, "Share via:"));
转载于:https://blog.51cto.com/hexen/700825