title: Android: Error occured while loading photo
body: <p>I am making an attempt to crop an image from the Camera after taking photo so I have this solution:</p>
  
  <p>This is the onClick event to start the camera</p>
  
  <pre><code>public void onClick(View v) {
  
    PackageManager pm = getPackageManager();
  
      if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
  
     Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  
     i.putExtra(MediaStore.EXTRA_OUTPUT, MyFileContentProvider.CONTENT_URI);
  
     startActivityForResult(i, CAMERA_RESULT);
  
    } else {
  
     Toast.makeText(getBaseContext(), "Camera is not available", Toast.LENGTH_LONG).show();
  
    }   }
  </code></pre>
  
  <p>//This is the onActivityResult</p>
  
  <pre><code>@Override
  
   protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  
    super.onActivityResult(requestCode, resultCode, data);
  
    Log.i(Tag, "Receive the camera result");
  
      if (resultCode == RESULT_OK &amp;&amp; requestCode == CAMERA_RESULT) {
  
          performCrop();
  
     }else if( requestCode == 5){
  
         String path = this.imageFileUri.getPath();
         //Bitmap bit = decodeSampledBitmapFromPath(path, 600, 600);
  
  
       int rotate = 0;
       try {
           ExifInterface exif = new ExifInterface(
                   this.imageFileUri.getPath());
           int orientation = exif.getAttributeInt(
                   ExifInterface.TAG_ORIENTATION,
                   ExifInterface.ORIENTATION_NORMAL);
  
           switch (orientation) {
           case ExifInterface.ORIENTATION_ROTATE_270:
               rotate = 270;
               break;
           case ExifInterface.ORIENTATION_ROTATE_180:
               rotate = 180;
               break;
           case ExifInterface.ORIENTATION_ROTATE_90:
               rotate = 90;
               break;
           }
       } catch (Exception e) {
           e.printStackTrace();
       }
  
  
       Matrix matrix = new Matrix();
       matrix.postScale(0.5f, 0.5f);
       matrix.postRotate(rotate);
  
      // Bitmap bitmap = decodeFile(out);
       Bitmap bitmap = decodeSampledBitmapFromPath(path, 600, 600);
  
       //Bitmap mBitmap = BitmapFactory.decodeFile(out.getAbsolutePath());
      bitmap = Bitmap.createBitmap(bitmap, 1, 1, bitmap.getWidth() - 1, bitmap.getHeight() - 1,matrix,true);
  
  
  
     imageView1.setImageBitmap(bitmap);
  
    }
  
   }
  </code></pre>
  
  <p>This is the perform crop method</p>
  
  <pre><code>private void performCrop() {
       Intent var1 = new Intent("com.android.camera.action.CROP");
       File out = new File(getFilesDir(), "newImage.jpg");
       if(!out.exists()) {
  
              Toast.makeText(getBaseContext(),
  
                "Error while capturing image", Toast.LENGTH_LONG)
  
                .show();
  
              return;}
       this.imageFileUri = Uri.fromFile(out);
       var1.setDataAndType(this.imageFileUri, "image/*");
       System.out.println(this.imageFileUri.getPath());
       var1.putExtra("crop", "true");
       var1.putExtra("scale", true);
       var1.putExtra("return-data", false);
       var1.putExtra("output", this.imageFileUri);
       this.startActivityForResult(var1, 5);
    }
  </code></pre>
  
  <p>Currently issue is that after taking the result from the camera then onto load the crop method, It displays an error occurred while loading the photo. The Photo Editor could not be started. </p>
  
  <p>I have looked at my code and everything seems okay from here. 
  Kindly assist me on what I am getting wrong. </p>
  
  <p>Thanks.</p>