我有一个按钮,拍摄照片,在存储的ImageView的缩略图,当用户点击另一个按钮,它需要的是图像附加到电子邮件。附上相机电子邮件图像 - 机器人
香港专业教育学院遵循“拍摄照片只需”从Android网站的方向,但不包含附件。有人可以看到我出错的地方,我需要做些什么来解决它?
我对活动结果代码:
public void onActivityResult(int requestcode, int resultcode, Intent data) {
if (requestcode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {
if (resultcode == RESULT_OK) {
Bundle bundle = new Bundle();
bundle = data.getExtras();
Bitmap BMB;
BMB = (Bitmap) bundle.get("data");
Hoon_Image.setImageBitmap(BMB);
try {
createImageFile();
} catch (IOException e) {
e.printStackTrace();
}
mDrawable = Hoon_Image.getDrawable();
mBitmap = ((BitmapDrawable) mDrawable).getBitmap();
}
}
}
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
// Save a file: path for use with ACTION_VIEW intents
mCurrentPhotoPath = "file:" + image.getAbsolutePath();
return image;
}
我的电子邮件的意图:
if (Witness_response == "Yes"){
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Dob in a Hoon Report (Y)");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Hoon report has been recieved " + emailBody);
emailIntent.putExtra(Intent.EXTRA_STREAM, mCurrentPhotoPath);
emailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(emailIntent, "Choose email client..."));
} else if (Witness_response == "No"){
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Dob in a Hoon Report (N)");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Hoon report has been recieved " + emailBody);
emailIntent.putExtra(Intent.EXTRA_STREAM, mCurrentPhotoPath);
emailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(emailIntent, "Choose email client..."));
}
谢谢如此令人难以置信的多!这一直让我疯狂! – scb998 2014-09-30 01:10:48