我使用下一个代码,但我有一个例外:
FileOutputStream out = new FileOutputStream(pic);
这是我使用的功能:" frame"是来自相机的令牌的Bitmap,我在ImageView上显示它。 " PIC"是一个文件。
public void sendEmail(View view) {
String email = "michael@gmail.com";
String subject = "frame";
String message = "This is the frame!";
try {
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()){
pic = new File(root, "image.jpeg");
FileOutputStream out = new FileOutputStream(pic);
frame.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
}
} catch (IOException e) {
}
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("image/jpeg");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, message);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(pic));
startActivity(Intent.createChooser(emailIntent, "Sending email..."));
}