title: Cropping image issue when taken from camera
body: <p>Below is my related <code>code snippet</code> where in it redirects to the device's <code>cropping app</code> after the picture has been shot from the camera. I usually followed this <a href="http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/"><strong>example</strong></a>. But during the phase/moment between the picture taken from camera and making that available in crop app, it shows continuously loading and makes my app terribly unresponsive. If this happens at least once, every time I open the app, it just shows loading. </p>
  
  <p>This issue doesn't occur in <code>one scenario</code>--> When I don't move my device(i.e., only when no screen orientation happens). Can some one please suggest me to avoid this issue?</p>
  
  <pre><code>public void shotFromCamera(View view)
  {
      Intent intent    = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageCaptureUri);
  
                  try {
                      intent.putExtra("return-data", true);
  
                      startActivityForResult(intent, PICK_FROM_CAMERA);
                  } catch (ActivityNotFoundException e) {
                      e.printStackTrace();
                  }
  }
  
  protected void onActivityResult(int requestCode, int resultCode,Intent data)
      {
          super.onActivityResult(requestCode, resultCode, data);
  
          if(resultCode==RESULT_OK &amp;&amp; requestCode == PICK_FROM_CAMERA){
  
              doCrop();
                   } else if(resultCode == RESULT_OK &amp;&amp; requestCode == CROP_FROM_CAMERA)
          {
              Bundle extras = data.getExtras();
  
              if (extras != null) {               
                  Bitmap photoBitmap = extras.getParcelable("data");
  
                  imageView.setImageBitmap(photoBitmap);
                  if(mImageCaptureUri != null)
                  {
                  File f = new File(mImageCaptureUri.getPath());
                  if (f.exists()) f.delete();
                  }
  
                  mImageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory()+ "/MyApp",
                             "avatar" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
                  File file = new File(mImageCaptureUri.getPath()); 
  
                      selectedImagePath = mImageCaptureUri.getPath();
                      Log.d("pic1 ","pic to be created: "+selectedImagePath);
                      OutputStream fOut = null;
  
                      try {
                          fOut = new FileOutputStream(file);
                          photoBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
                          fOut.flush();
                          fOut.close();
                      } catch (FileNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      } catch(IOException e)
                      {
                          e.printStackTrace();
                      }       
  
              }
  
  
          }
  }
  
      private void doCrop() {
              final ArrayList&lt;CropOption&gt; cropOptions = new ArrayList&lt;CropOption&gt;();
              Intent intent = new Intent("com.android.camera.action.CROP");
              intent.setType("image/*");
  
              List&lt;ResolveInfo&gt; list = getPackageManager().queryIntentActivities( intent, 0 );
  
              int size = list.size();
  
              if (size == 0) {            
                  Toast.makeText(this, "Can not find image crop app", Toast.LENGTH_SHORT).show();
  
                  return;
              } else {
                  intent.setData(imageCaptureUri);
  
                  intent.putExtra("outputX", 200);
                  intent.putExtra("outputY", 200);
                  intent.putExtra("aspectX", 1);
                  intent.putExtra("aspectY", 1);
                  intent.putExtra("scale", true);
                  intent.putExtra("return-data", true);
  
                  if (size == 1) {
                      Intent i        = new Intent(intent);
                      ResolveInfo res = list.get(0);
  
                      i.setComponent( new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
  
                      startActivityForResult(i, CROP_FROM_CAMERA);
                  }
     }
  </code></pre>
  
  <p>To clarify my issue, I had run the source code in that example as it is, the same issue happens. I had run other couple of examples which redirect to the cropping app. The same issue happens while changing the orientation during the above explained phase.</p>
  
  <p><strong>P.S</strong> : If anyone has working example which surely works even on orientation changes, I would be glad to accept it as an answer.</p>