title: Android media thumbnails. Serious issues?
body: <p>I've been playing with android's thumbnails for a while now, and I've seen some inconsistencies that make me want to scream. My goal is to have a simple list of all Images (and a separate list for video) with the thumbnail and filename.</p>
  
  <p>Device: HTC Evo (fresh from Google I/o)</p>
  
  <p>First off: 
  <a href="http://androidsamples.blogspot.com/2009/06/how-to-display-thumbnails-of-images.html" rel="nofollow noreferrer">http://androidsamples.blogspot.com/2009/06/how-to-display-thumbnails-of-images.html</a></p>
  
  <p>That code doesn't seem to work at all, thumbnails are duplicated... some with the "mirror" effect and some without. Also some won't load and just display a black square. I've tried rebuilding the thumbnails by deleting the "alblum thumbs" directory from the SD card. HTC's gallery application seem to show everything fine.</p>
  
  <p>This approach seems to work:</p>
  
  <pre><code>Bitmap thumb = MediaStore.Images.Thumbnails.getThumbnail(
      getContentResolver(),
      id, MediaStore.Video.Thumbnails.MICRO_KIND, null);
  imageView.setImageBitmap(curThumb);
  </code></pre>
  
  <p>where id is the <em>original</em> images id and imageView is some image view. This is great! But, strangely, way too slow to be used inside a SimpleViewBinder. Next approach:</p>
  
  <pre><code>String [] proj = {MediaStore.Images.Thumbnails._ID};
  Cursor c = managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
      proj, MediaStore.Images.Thumbnails.IMAGE_ID + "=" +id ,
      null, null);
  
  if (c != null &amp;&amp; c.moveToFirst()) {
      Uri thumb = Uri.withAppendedPath(mThumbUri,c.getLong(0)+"");
      imageView.setImageURI(thumb);
  }
  </code></pre>
  
  <p>I should explain that I feel the needed WHERE condition is required because there doesn't seem to be any guarantee that your uri will have the same ID for both a thumbnail and its parent image.  This works for all of the current images, but as soon as I start adding pictures with the camera they show up as blank! Debugging shows a dreaded:</p>
  
  <pre><code>SkImageDecoder::Factory returned null
  </code></pre>
  
  <p>error and the URI is returned as invalid. These are the same images that work with the previous call. Can anyone either catch my logical failure or point me to some working code?</p>