开发者

How to attach an image which is stored locally to an Email in android?

开发者 https://www.devze.com 2023-01-30 13:12 出处:网络
I am new to Android. I need to attach an image to an email. The image is stored l开发者_运维知识库ocally. Is it possible? Thanks in advance.If you\'re looking to take a locally stored file and attach

I am new to Android. I need to attach an image to an email. The image is stored l开发者_运维知识库ocally. Is it possible? Thanks in advance.


If you're looking to take a locally stored file and attach it to an e-mail, you can do the following:

String filename = "/path/to/yourfile.png";
File F = new File(filename);
Uri U = Uri.fromFile(F);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("image/png");
i.putExtra(Intent.EXTRA_STREAM, U);
startActivity(Intent.createChooser(i,"Send Image To:"));

This will let the user select the e-mail program he wants to use and attach the image to the resulting message.

0

精彩评论

暂无评论...
验证码 换一张
取 消