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.
精彩评论