title: Failure delivering result ResultInfo{who=null In taking photo with Camera
body: <p>I Saw another questions about this problem but non of them helped.</p>
  
  <p>In my app there two different ways for adding an image and displaying it inside an imageview. 1. Gallery - 2. Camera.</p>
  
  <p>gallery way is working just fine.</p>
  
  <p>But in Camera way (which I'm doing it with native android Camera) I have a confusing problem.</p>
  
  <p>If I rotate my phone to portrait mode (so the portrait xml loads) and take the photo in portrait mode, it works fine.</p>
  
  <p>If I rotate it to landscape and use use camera also in landscape, it works fine too.</p>
  
  <p>now if my xml is in portrait and after going to camera I rotate it to landscape (to take a lansdcape photo) app crashes and gives me this Errors:</p>
  
  <pre><code>05-08 21:34:22.974: E/AndroidRuntime(19000): FATAL EXCEPTION: main
  05-08 21:34:22.974: E/AndroidRuntime(19000): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.kpaxteam.babyalbum/com.tiktak.albums1.A2}: java.lang.NullPointerException
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2918)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:2970)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.app.ActivityThread.access$2000(ActivityThread.java:132)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1068)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.os.Handler.dispatchMessage(Handler.java:99)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.os.Looper.loop(Looper.java:150)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.app.ActivityThread.main(ActivityThread.java:4277)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at java.lang.reflect.Method.invokeNative(Native Method)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at java.lang.reflect.Method.invoke(Method.java:507)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at dalvik.system.NativeStart.main(Native Method)
  05-08 21:34:22.974: E/AndroidRuntime(19000): Caused by: java.lang.NullPointerException
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.content.ContentResolver.acquireProvider(ContentResolver.java:745)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.content.ContentResolver.query(ContentResolver.java:258)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at com.tiktak.babyalbum.Helper.pathgal(Helper.java:161)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at com.tiktak.babyalbum.Helper.resultpic(Helper.java:299)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at com.tiktak.albums1.A2.onActivityResult(A2.java:242)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.app.Activity.dispatchActivityResult(Activity.java:4053)
  05-08 21:34:22.974: E/AndroidRuntime(19000):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2914)
  </code></pre>
  
  <p>My Intent for taking photo:</p>
  
  <pre><code>                       Intent cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
                         cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);  
                         act.startActivityForResult(cameraIntent, int2);
  </code></pre>
  
  <p>My ActivityResult:</p>
  
  <pre><code>else if (requestCode == CAMERA_REQUEST) {
          if (resultCode == RESULT_OK) {
   Helper line 299---&gt;        String capturedImageFilePath = Helper.pathgal(act, mCapturedImageURI);
              bmp = Helper.decodeFile(capturedImageFilePath, act);
              if(bmp != null )
              {
                  try {
                      Helper.showpic(act, id1, bmp);
                      settings = act.getSharedPreferences(st1, 0);
                      settings.edit().putString(st2, capturedImageFilePath).putInt(st3, View.VISIBLE).putInt(st4, View.GONE).commit();;
                      img1 = (ImageView) act.findViewById(id1);
                      img2 = (ImageView) act.findViewById(id2);
                      img1.setVisibility(View.VISIBLE);
                      img2.setVisibility(View.GONE);
                  } catch (OutOfMemoryError e) {
                      Toast.makeText(act.getApplicationContext(), "Try Again",
                              Toast.LENGTH_LONG).show();
                  }
  
  
              }
  </code></pre>
  
  <p>getting image file path code:</p>
  
  <pre><code>public static String pathgal(Activity act, Uri uri){
  
      String[] filePathColumn = {MediaStore.Images.Media.DATA};
  
   Helper 161---&gt;   Cursor cursor = act.getContentResolver().query(uri, filePathColumn, null, null, null);
  
      if (cursor != null) {
      cursor.moveToFirst();
  
      int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
      String filePath = cursor.getString(columnIndex);
      cursor.close();
  
      return filePath;
      }
      return null;
  
  }
  </code></pre>
  
  <p>any idea?</p>