title: Camera picture returning null url. (Android)
body: <p>Every time I take a picture with my camera it sets selectedImageUri to null...</p>
  
  <p>Also, DATA IS NOT NULL and ACTION IS NOT NULL get called, as to my confusion... I am not sure if I am doing something wrong let me know, the selectedImageUri when taking a picture should return as the Uri and not null</p>
  
  <p>Here is my code:</p>
  
  <pre><code> public void onActivityResult(int requestCode, int resultCode, Intent data) {
          if (resultCode == getActivity().RESULT_OK) {
              if (requestCode == YOUR_SELECT_PICTURE_REQUEST_CODE) {
                  final boolean isCamera;
                  if (data == null) {
                      Log.e("data", "DATA IS NULL");
                      isCamera = true;
                  } else {
                      Log.e("data", "DATA IS NOT NULL");
                      final String action = data.getAction();
                      //Log.e("PICTURE PATH?", action);
                      if (action == null) {
                          Log.e("data", "ACTION IS NULL");
                          isCamera = false;
                      } else {
                          Log.e("data", "ACTION IS NOT NULL");
                          isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  
                      }
                  }
  
                  Uri selectedImageUri;
                  if (isCamera) {
                      selectedImageUri = outputFileUri;
                      String uploadurl = "discover/p";
                      File photoSelected = new File(selectedImageUri.getPath());
                      TypedFile photo = new TypedFile("application/octet-stream", photoSelected);
                      String userId = "userId1";
                      Callback cameraResponse = new Callback() {
                          @Override
                          public void success(Object o, Response response) {
  
                          }
  
                          @Override
                          public void failure(RetrofitError retrofitError) {
                              Log.e("TAG", retrofitError.getMessage());
                          }
                      };
                      uploadImage(uploadurl, photo, userId, cameraResponse);
                      Picasso.with(getActivity()).load(selectedImageUri.getPath()).into(profilePicture);
                  } else {
                      if (data == null) {
                          selectedImageUri = null;
                      } else {
                          selectedImageUri = data.getData();
                          Log.e("gallery image", "link is " + data.getData());
                          String uploadurl = "discover/p";
                          File photoSelected = new File(String.valueOf(selectedImageUri));
                          TypedFile photo = new TypedFile("application/octet-stream", photoSelected);
                          String userId = "userId1";
                          Callback galleryResponse = new Callback() {
                              @Override
                              public void success(Object o, Response response) {
  
                              }
  
                              @Override
                              public void failure(RetrofitError retrofitError) {
  
                              }
                          };
                          uploadImage(uploadurl, photo, userId, galleryResponse);
  
                          Picasso.with(getActivity()).load(selectedImageUri).into(profilePicture);
                      }
  
                  }
              }
          }
      }
  </code></pre>
  
  <p>EDIT including camera code:</p>
  
  <pre><code>if(isDeviceSupportCamera()) {
                  // Determine Uri of camera image to save.
                  final File root = new File(Environment.getExternalStorageDirectory() + File.separator + "MyDir" + File.separator);
                  root.mkdirs();
                  final String fname = getUniqueImageFilename();
                  final File sdImageMainDirectory = new File(root, fname);
                  outputFileUri = Uri.fromFile(sdImageMainDirectory);
                  Log.e("is camera ", "even getting CALLED CAM1111?");
                  // Camera.
                  final List&lt;Intent&gt; cameraIntents = new ArrayList&lt;Intent&gt;();
                  Log.e("is camera ", "even getting CALLED CAM?222");
                  final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                  final PackageManager packageManager = getActivity().getPackageManager();
                  final List&lt;ResolveInfo&gt; listCam = packageManager.queryIntentActivities(captureIntent, 0);
                  Log.e("is camera ", "even getting CALLED CAM333?");
                  for (ResolveInfo res : listCam) {
                      Log.e("is camera ", "even getting CALLED CAM4444?");
                      final String packageName = res.activityInfo.packageName;
                      final Intent intent = new Intent(captureIntent);
                      intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
                      intent.setPackage(packageName);
                      intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
                      cameraIntents.add(intent);
                  }
                  Log.e("is camera ", "even getting CALLED CAM?5555");
  
                  final Intent chooserCameraIntent = Intent.createChooser(captureIntent, "Use Camera");
  
                  startActivityForResult(chooserCameraIntent, YOUR_SELECT_PICTURE_REQUEST_CODE);
  
                  } else {
                       Toast.makeText(getActivity(), "There is no camera available on this device.", Toast.LENGTH_SHORT).show();
                  }
  
              }
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>Log File:</p>
  
  <pre><code>03-12 10:20:21.854  27814-27814/com.example.app E/data﹕ CAMERA IS NOT NULL outputfileuri is file:///storage/emulated/0/MyDir/img_userID1%20_1394612413661.jpg
  03-12 10:20:21.854  27814-27814/com.example.app E/data﹕ camera link for selectedImageUri file:///storage/emulated/0/MyDir/img_userID1%20_1394612413661.jpg
  03-12 10:20:21.854  27814-27814/com.example.app E/data﹕ selected image get path link is /storage/emulated/0/MyDir/img_userID1 _1394612413661.jpg
  </code></pre>
  
  <p>I also added true to isCamera instead of </p>
  
  <pre><code>action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  </code></pre>
  
  <p>if I add this code under my if request code</p>
  
  <pre><code> if (resultCode == getActivity().RESULT_OK) {
              if (requestCode == YOUR_SELECT_PICTURE_REQUEST_CODE) {
  //                Bundle extras = data.getExtras();
  //                Bitmap imageBitmap = (Bitmap) extras.get("data");
  //                profilePicture.setImageBitmap(imageBitmap);
                 final boolean isCamera;
  </code></pre>
  
  <p>It actually shows the image in the image view... so I am confused as to why it is not getting the uri right.</p>
  
  <p>This is the android manifest permission</p>
  
  <pre><code>&lt;!-- For Camera use and downloading image --&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  
      &lt;!-- internet --&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>