title: Android startActivityForResult returns null to onActivityResult when using camera
body: <p>I am having a problem with startActivityForResult/onActivityResult where data returns null. I use startActivityForResult(camera) and manage to save the image into the device. </p>
  
  <p>This is the piece in the activity that calls the Camera</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.upload_new_tire);
      setUpWings();
  
      imageButton.setOnClickListener(new MyCamera(this));
  }
  </code></pre>
  
  <p>This is my onActivityResult function</p>
  
  <pre><code>protected void onActivityResult(int requestCode,int resultCode, Intent data){
      Log.i("request, result Code", String.valueOf(requestCode) + " and " + String.valueOf(resultCode));
      super.onActivityResult(requestCode, resultCode, data);
      if (requestCode == REQUEST_IMAGE_CAPTURE &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null){
          Bundle extras = data.getExtras();
          Bitmap imageBitmap = (Bitmap)extras.get("data");
          imageButton.setImageBitmap(imageBitmap);
      }
  }
  </code></pre>
  
  <p>This is where I call startActivityForResult and save the image to file. </p>
  
  <pre><code>Uri photoURI = FileProvider.getUriForFile(mContext,
                      "autosoftpro.reusedtire.fileprovider",
                      photoFile);
              takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
              mContext.startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
  </code></pre>
  
  <p>This is the error message, it happens because 'Intent data' is null. I have tried to look at other posts which are similar but didn't manage to figure out the reason why.</p>
  
  <pre><code>java.lang.RuntimeException: Failure delivering result 
  ResultInfo{who=null, request=1, result=-1, data=null} to activity {autosoftpro.reusedtire/autosoftpro.reusedtire.UploadTireActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Bundle android.content.Intent.getExtras()' on a null object reference
  </code></pre>