title: How to properly error-catch Android camera activity when using the ACTION_IMAGE_CAPTURE Intent
body: <p>In Android, taking a picture can be done with this basic setup as seen <a href="http://developer.android.com/training/camera/photobasics.html" rel="nofollow">here</a>.</p>
  
  <pre><code>protected void dispatchTakePictureIntent(){
      Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
  
          ...
          takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); 
          startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
      }
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (requestCode == REQUEST_IMAGE_CAPTURE &amp;&amp; resultCode == RESULT_OK) {
          //do stuff with the output file
      }
  }
  </code></pre>
  
  <p>However, <a href="https://commonsware.com/blog/2015/06/08/action-image-capture-fallacy.html" rel="nofollow">third-party camera apps are unpredictable and cannot be guaranteed to play nice</a>.</p>
  
  <p>What is the correct way to validate the output / catch any errors? Should I be wrapping <code>startActivityForResult</code> inside of a try/catch block? What are the various types of exceptions I should be trying to catch and what should I do with them?</p>