title: Failure delivering result ResultInfo{} to activity for some pictures
body: <p>I have created application which allow user to add photo from gallery or directly from camera. For some pictures it's working correctly but for some app is stoped. Why it's working only for some pictures?</p>
  
  <pre><code> @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if (resultCode==RESULT_OK){
              if(requestCode==SELECT_FROM_GALLERY||requestCode==TAKE_A_PICTURE){
  
                  Uri selectedImage;
                  if(requestCode==SELECT_FROM_GALLERY) {
                      selectedImage = data.getData();
                      picUri=selectedImage;
                  }else
                  selectedImage=picUri;
                  InputStream imageStream = null;
                  try {
                      imageStream = getContentResolver().openInputStream(selectedImage);
                  } catch (FileNotFoundException e) {
                      e.printStackTrace();
                  }
                  Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream);
                  Intent intent = new Intent("com.android.camera.action.CROP");
                  String path  = MediaStore.Images.Media.insertImage(getContentResolver(), yourSelectedImage, null, null);
                  Uri uri = Uri.parse(path);
                  intent.setData(uri);
    // intent.putExtra("crop", "true");
      //                intent.putExtra("aspectX", 1);
      //                intent.putExtra("aspectY", 1);
                      intent.putExtra("outputX", 500);
                      intent.putExtra("outputY", 500);
                      intent.putExtra(MediaStore.EXTRA_OUTPUT, picUri);
                      intent.putExtra("noFaceDetection", true);
                      intent.putExtra("return-data", true);
                      startActivityForResult(intent, CROP_THE_PICTURE);
                  }else if (requestCode==CROP_THE_PICTURE){
                      Uri selectedImage = data.getData();
                      ContentValues cv = new ContentValues();
                      cv.put(DateContract.DateEntry.UCZNIOWIE_COLUMN_PICTURE_URI,selectedImage.toString());
                      SQLiteDatabase db=(new DateDbHelper(context,serverToPhoto)).getWritableDatabase();
                      cv.put(DateContract.DateEntry.UCZNIOWIE_COLUMN_PICTURE_URI,selectedImage.toString());
                      db.update(DateContract.DateEntry.DB_TABLE_UCZNIOWIE,cv, DateContract.DateEntry.UCZNIOWIE_COLUMN_ID_UCZNIA+"="+pupilIdToPhoto,null);
  
                  }
              }
          }
  </code></pre>
  
  <p>logs:     </p>
  
  <pre><code>java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=3, result=-1, data=Intent { (has extras) }} to activity {pl.mobidziennik.rodzic/pl.mobidziennik.rodzic.LoginActivity}: java.lang.NullPointerException
      at android.app.ActivityThread.deliverResults(ActivityThread.java:3205)
      at android.app.ActivityThread.handleSendResult(ActivityThread.java:3248)
      at android.app.ActivityThread.access$1200(ActivityThread.java:140)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:137)
      at android.app.ActivityThread.main(ActivityThread.java:4921)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
      at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
      at pl.mobidziennik.rodzic.LoginActivity.onActivityResult(LoginActivity.java:194)
      at android.app.Activity.dispatchActivityResult(Activity.java:5390)
      at android.app.ActivityThread.deliverResults(ActivityThread.java:3201)
      ... 11 more
  </code></pre>
  
  <p>I think it depends on size of picture.</p>