我有一个保存在外部存储器中的位图。我已经有一个加载和返回位图的方法。我的问题是,如何将此图像附加到电子邮件意图中。
注意:我知道如何启动电子邮件意图,我只需要知道如何附加位图。谢谢。
这就是我保存图片的方式:
private void savePicture(String filename, Bitmap b, Context ctx) {
try {
FileOutputStream out;
out = ctx.openFileOutput(filename, Context.MODE_WORLD_READABLE);
b.compress(Bitmap.CompressFormat.JPEG, 40, out);
if (b.compress(Bitmap.CompressFormat.JPEG, 40, out) == true)
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
尝试使用电子邮件附加图像
从 SdCard 获取图像
String path = Environment.getExternalStorageDirectory().toString();
File file = new File(path,"YourImageName.JPEG");
Uri pngUri = Uri.fromFile(file);
电子邮件意图
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, pngUri);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)