我需要在我的Android应用程序中拍摄设置为ImageView的照片,并在按钮后单击打开电子邮件应用程序并将此照片作为附件。
File photoFile;
按钮拍摄照片事件:
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
活动结果:
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
imageView.setImageBitmap(imageBitmap);
//photoFile how to set path of imageBitmap ?
}
并发送无效的电子邮件按钮...(java.lang.NullPointerException:file)
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"fake@fake.edu"});
intent.putExtra(Intent.EXTRA_SUBJECT,"On The Job");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(photoFile));
intent.setType("image/png");
startActivity(Intent.createChooser(intent,"Share you on the jobing"));