我怎么可以附加在电子邮件中的图像文件?加在、图像文件、电子邮件、我怎么

2023-09-12 08:06:21 作者:躲进棺材思考人生

我要附加图像的电子邮件,该图像存储在 /data/data/mypacke/file.png 。我怎么可以附加图像文件编程?什么样code样子?

I want to attach an image with email, that image is stored in /data/data/mypacke/file.png. How can I attach that image file programmatically? What would sample code look like?

推荐答案

使用Intent.ACTION_SEND手的形象给另一个程序。

Use Intent.ACTION_SEND to hand the image off to another program.

File F = new File("/path/to/your/file.png");
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,"Email:"));