title: How to capture image thumbnail AND save file in a custom folder in Android
body: <p>I am trying to capture an image from an existing camera application, save the image in a customized folder, and display the thumbnail in and imageView. The camera supplies the thumbnail as long as I haven't specified where to save the file:</p>
  
  <p>I can get the thumbnail from the returned intent:</p>
  
  <pre><code>...
    Intent i = = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(i)
  }
  
  protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);      
    Bundle extras = intent.getExtras();
    Bitmap mImageBitmap = (Bitmap) extras.get("data");
  }
  </code></pre>
  
  <p>Or I can save the file in a specified folder (which works fine) </p>
  
  <pre><code>  ...
    Intent i = = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    i.putExtra((MediaStore.EXTRA_OUTPUT, outputFileUri);
    startActivityForResult(i)
  }
  </code></pre>
  
  <p>but the thumbnail is no longer stored in the intent extra "data", and when I try to retrieve the thumbnail, I get an error (this is from my LogCat)</p>
  
  <pre><code>10-04 06:30:14.463: E/AndroidRuntime(1967): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity: java.lang.NullPointerException
  </code></pre>
  
  <p>As you can see, the field returned is null instead of the bitmap thumbnail. I have tried decoding the bitmap afterwards to generate a thumbnail from the file directly, but it takes too long (even when downsampled I get out of memory error) , and it seems counterintuitive to do the job twice. Any suggestions?</p>