title: My Android camera Uri is returning a null value, but the Samsung fix is in place, help?
body: <p>So I am aware of the camera's issue on Samsung devices. You need to create a Uri before calling the camera intent like so:</p>
  
  <pre><code>Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  ContentValues values = new ContentValues();
  values.put(MediaStore.Images.Media.TITLE, m_username);
  mImageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
  cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
  startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
  </code></pre>
  
  <p>This example creates a Uri for the camera to store the data in. My app has a camera function in two locations. Both are identical (direct copy paste), but in one activity the <code>mImageUri</code> object becomes null during the camera process, while in the other it doesn't. The latter works fine, but the former gives a null value which in turn stops me from saving the image, previewing it, etc. I will provide the onResult code below:</p>
  
  <pre><code>case CAMERA_PIC_REQUEST :
  if(resultCode == RESULT_OK) {
      if(intent != null) {
          //For non-Samsung devices
          Log.e("Intent value:", intent.toString());
          mImageUri = intent.getData();
      }
  
      mAvatar = BitmapStatic.createImage(mImageUri, this);
      Drawable draw = new BitmapDrawable(getResources(), mAvatar);
      m_photoButtonE.setImageDrawable(draw);
      m_imageChanged = true;
  }
  break;
  </code></pre>
  
  <p>The above example is from the working activity. Below is the activity where this doesn't work:</p>
  
  <pre><code>//On pressing the "Take Photo" button:
  Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  ContentValues values = new ContentValues();
  values.put(MediaStore.Images.Media.TITLE, mUsername);
  mImageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
  if(mImageUri == null) {
      Log.e("image uri is null", "what?");
  }
  else {
      Log.e("oh nevermind", "image uri is NOT null");
  }
  cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
  startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
  
  //On Result:
  case CAMERA_PIC_REQUEST :
  if(resultCode == RESULT_OK) {
      if(intent != null) {
          Log.e("Intent value:", intent.toString());
          mImageUri = intent.getData();
      }
      else {
          Log.e("Intent is null", "yep it is.");
          if(mImageUri == null) {
              Log.e("nullcheck on memberimageuri", "its null");
          }
          else {
              Log.e("nullcheckon memberimage", mImageUri.toString());
          }
      }
      mImage = BitmapStatic.createImage(mImageUri, this);
      Drawable draw = new BitmapDrawable(getResources(), mImage);
      mPhotoPreview.setImageDrawable(draw);
  }
  break;
  </code></pre>
  
  <p>Notice the log files I have put in this 2nd example. When I click the "Take Picture" button, the null check for the <code>mImageUri</code> object returns true. So this object is not null. But somewhere during the picture taking process that value DOES become null. The 2nd check during onResult() returns false. Again, this is almost identical to my setup in the other activity, where it works fine.</p>
  
  <p>Any thoughts?</p>