title: Camera is not working in Nougat 7.0
body: <p>My camera code is working in all Android versions but in Nougat 7.0 it gives the following error: </p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
  </code></pre>
  
  <p>It is working perfectly on all other versions of android except on android 7.0. I have given run time permission for the camera &amp; the gallery but the camera is still not working. Here is the relevant code:</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  
      if (resultCode == RESULT_OK) {
          if(requestCode == Constants.CROPPED_PIC_REQUEST_CODE){
              CropImage.ActivityResult result = (CropImage.ActivityResult) data.getExtras().get(CropImage.CROP_IMAGE_EXTRA_RESULT);
              Uri selectedImageUri = result == null ? null : result.getUri();
              Bitmap bitmap = null;
              Log.d("SetUpProfile","Uri cropped is "+outputFileUri);
              bitmap = getBitmap(selectedImageUri);
      //                    bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImageUri);
              circleImageView.setImageBitmap(bitmap);
              finalBitmap = bitmap;
          }
          else if (requestCode == Constants.YOUR_SELECT_PICTURE_REQUEST_CODE) {
              final boolean isCamera;
              if (data == null) {
                  isCamera = true;
              } else {
                  final String action = data.getAction();
                  if (action == null) {
                      isCamera = false;
                  } else {
                      isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                  }
              }
  
              Uri selectedImageUri;
              if (isCamera) {
                  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
                  String value = prefs.getString("path", "error");
                  selectedImageUri = Uri.parse(value);
              } else {
                  selectedImageUri = data == null ? null : data.getData();
              }
  
              Intent i = new Intent(Five.this,CropImageActivity.class);
              i.putExtra("ImageURI", selectedImageUri.toString());
              startActivityForResult(i,Constants.CROPPED_PIC_REQUEST_CODE);
  
          }
      }
  }
  </code></pre>
  
  <p>Here is my logcat:- </p>
  
  <pre><code>FATAL EXCEPTION: main
  Process: com.sancsvision.wayndr, PID: 31570
  java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=11, result=-1, data=Intent {  }} to activity {com.sancsvision.wayndr/com.sancsvision.wayndr.Five}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference                     
      at android.app.ActivityThread.deliverResults(ActivityThread.java:4053)              
      at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096)        
      at android.app.ActivityThread.-wrap20(ActivityThread.java)                      
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516)         
      at android.os.Handler.dispatchMessage(Handler.java:102)                     
      at android.os.Looper.loop(Looper.java:154)                      
      at android.app.ActivityThread.main(ActivityThread.java:6077)                        
      at java.lang.reflect.Method.invoke(Native Method)                       
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)      
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)                                                     
  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
      at com.sancsvision.wayndr.Five.onActivityResult(Five.java:259)
      at android.app.Activity.dispatchActivityResult(Activity.java:6917)
      at android.app.ActivityThread.deliverResults(ActivityThread.java:4049)
      at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096) 
      at android.app.ActivityThread.-wrap20(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:154) 
      at android.app.ActivityThread.main(ActivityThread.java:6077) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  </code></pre>