我有一個按鈕,拍攝照片,在存儲的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