如何安装图像视图作为电子邮件附件? [英] How to attach image view as an email attachment?

查看:153
本文介绍了如何安装图像视图作为电子邮件附件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我生成的图像视图饼图,我希望通过电子邮件发送。

I am generating pie chart on image view, I want to send it via email.

如何转换图像视图的形象,以邮件附件,因为它不具备的资源?

How to convert image view's image to email attachment, as its not available in resources?

推荐答案

呼叫 getDrawingCache()你的图像视图。这将返回视图的缓存位图。这里阅读文档

Call getDrawingCache() on your image view. This returns the cache bitmap of the view. Read documentation here.

保存位图PNG,创建邮件,并附加和发送。

Save the bitmap as PNG, create a mail and attach and send.

Bitmap bmp = imgView.getDrawingCache();
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_WORLD_READABLE);
bmp.compress(Bitmap.CompressFormat.PNG, 0, fos);
fos.close();

/* Create a Action_SEND intent and attach the FILENAME image to the mail. */
...
intent.putExtra(Intent.EXTRA_STREAM, FILENAME); // FILENAME is URI
...
startActivity(....);

这篇关于如何安装图像视图作为电子邮件附件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆