Android capture photo putExtra (MediaStore.EXTRA_OUTPUT, Uri.fromFile (photoFile)); Данные равны нулю

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( "MyImages"); storageDir.mkdirs(); // File imagesFolder = new File(Environment.getExternalStorageDirectory(), "MyImages"); 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; } 

Static final int REQUEST_TAKE_PHOTO = 1;

 private void dispatchTakePictureIntent() { takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go photoFile = null; try { photoFile = createImageFile(); } catch (IOException ex) { // Error occurred while creating the File //... } // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photoFile)); //takePictureIntent = getIntent().putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO); } } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) { if(data != null) { Bitmap photo = (Bitmap) data.getExtras().get("data"); imageView.setImageBitmap(photo); } } } 

main.xml

 <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.59" android:text="File Uri" /> <ImageView android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="50dp" android:layout_weight="0.52" android:maxHeight="@dimen/max_image_height" android:src="@drawable/ic_launcher" /> 

Привет, я хочу сфотографировать и сохранить в файл «MyImages», который я создаю, и я хочу просмотреть фотографию. Я могу сделать фотографию и сохранить ее, но я не могу просмотреть изображение. putExtra (MediaStore.EXTRA_OUTPUT, Uri.fromFile (photoFile)); Данные являются нулевыми из-за Uri.fromFile (photoFile). Пожалуйста помоги!