title: How to get the URI from a camera intent?
body: <p>I have already read this post: <a href="https://stackoverflow.com/questions/21388586/get-uri-from-camera-intent-in-android">Get uri from camera intent in android</a> but it didn't help me.</p>
  
  <p>To handle the camera request I've used this code:</p>
  
  <pre><code>    public void startCamera() {
      if (PermissionUtils.requestPermission(
              this,
              CAMERA_PERMISSIONS_REQUEST,
              Manifest.permission.READ_EXTERNAL_STORAGE,
              Manifest.permission.CAMERA)) {
          //Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
          Uri photoUri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".provider", getCameraFile());
          intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
          intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
          startActivityForResult(intent, CAMERA_IMAGE_REQUEST);
      }
  }
  
  
   public File getCameraFile() {
      File dir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
      return new File(dir, FILE_NAME);
  }
  
  
      @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      if (requestCode == CAMERA_IMAGE_REQUEST &amp;&amp; resultCode == RESULT_OK) {
          Uri photoUri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".provider", getCameraFile());
          uploadImage(photoUri);
      }
  }
  </code></pre>
  
  <p>When I call the function "startCamera" the app crashes giving me error at the line:</p>
  
  <pre><code>Uri photoUri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".provider", getCameraFile());"
  </code></pre>
  
  <p>Any help? Thank you!</p>