title: Android getting thumbnail Uri after getting picture from the Camera
body: <p>I do not want to use any bitmap resizing code if I can help it.
  I have a method to get a MINI thumbnail uri when I get pictures from the Gallery but when I try to do the same with the Camera it does not work:</p>
  
  <p>Here are the methods:</p>
  
  <pre><code>private Uri getParsedUri(Uri selectedImageUri) {
      Uri parsed = null;
      try {
          String uri = getThumbnailPath(selectedImageUri);
  
          if (uri != null) {
              Timber.d("Thumb uri found %s", uri);
              File file = new File(uri);
              parsed = Uri.fromFile(file);
              Timber.d("thumb uri parsed : %s", parsed);
          } else {
              Timber.d("Thumb uri not found, using :  %s", selectedImageUri);
          }
      } catch (Exception e){
          Timber.e(e, "Error getting mini uri");
      }
      return parsed;
  }
  
  private String getThumbnailPath(Uri uri) {
      String[] projection = { MediaStore.Images.Media._ID };
      String result = null;
      Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
      if (cursor != null &amp;&amp; cursor.getCount() &gt; 0) {
          int column_index = cursor
                  .getColumnIndexOrThrow(MediaStore.Images.Media._ID);
  
          cursor.moveToFirst();
          long imageId = cursor.getLong(column_index);
          cursor.close();
  
          Cursor cursor2 = MediaStore.Images.Thumbnails.queryMiniThumbnail(
                  getContentResolver(), imageId,
                  MediaStore.Images.Thumbnails.MINI_KIND,
                  null);
          if (cursor2 != null &amp;&amp; cursor2.getCount() &gt; 0) {
              cursor2.moveToFirst();
              result = cursor2.getString(cursor2.getColumnIndexOrThrow(MediaStore.Images.Thumbnails
                      .DATA));
              cursor2.close();
          }
      }
      return result; //always null for pictures from the Camera
  }
  </code></pre>
  
  <p>Here is how I provide the uri extra for the Camera app:</p>
  
  <pre><code>private void onTakePhotoFromCameraClick() {
      final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  //        takePicUri = Uri.fromFile(getTempFile(ProductNewActivity.this));
      takePicUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
              new ContentValues());
      intent.putExtra(MediaStore.EXTRA_OUTPUT,
              takePicUri);
      startActivityForResult(intent, OPTION_TAKE_PHOTO_FROM_CAMERA);
  }
  
  
  private File getTempFile(Context context) {
       final File path = new  File(Environment.getExternalStorageDirectory(),
              context.getPackageName());
      if (!path.exists()) {
          path.mkdir();
      }
      long millis = new Date().getTime();
      String name_file = String.valueOf(millis);
      File tempImageFile = new File(path, "MyImage_" + name_file + ".tmp");
      return tempImageFile;
  }
  </code></pre>
  
  <p>both of the methods of getting the Uri (either using content resolver or creating my custom Uri, do not work and I am never able to get a thumbnail. Is there  a way to indicate the system to generate a thumbnail? Is the thumbnail always generated?. </p>
  
  <p>Edit: I think I did not explain clearly. I need 2 Uri: one for big image and one for a thumbnail. I do not need the bitmaps. I am using Universal Image Loader to display the images so I do not need the small bitmap. I generate the Uri for the big image myself but I would like to find a way for Android to generate the thumbnail since it already does it for pictures of the gallery.</p>