Reputation: 214
I have an app that queries the MediaStore and shows all the images in the gallery. Simple. It works well on my Nexus S, Droid X, and all flavors of the emulator. It gives wrong results on my Friends Evo (2.2) however. He sees only two images (out of 100 in his gallery). Here is the code:
// Where images are stored
Uri uri = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI;
// The columns we want
String[] projection = { MediaStore.Images.ImageColumns._ID, MediaStore.Images.Thumbnails.IMAGE_ID, MediaStore.Images.Thumbnails.KIND };
// Select only mini's
String selection = MediaStore.Images.Thumbnails.KIND + "=" + MediaStore.Images.Thumbnails.MINI_KIND;
mCursor = this.managedQuery(uri, projection, selection, null, null);
mCursor.moveToFirst();
return mCursor;
Fairly simple and common. Here is the ImageAdapter:
View vi=convertView;
ViewHolder holder;
if(convertView==null){
vi = inflater.inflate(R.layout.image_item, null);
holder=new ViewHolder();
holder.text=(TextView)vi.findViewById(R.id.text);;
holder.image=(ImageView)vi.findViewById(R.id.image);
vi.setTag(holder);
}
else {
holder=(ViewHolder)vi.getTag();
}
mCursor.requery();
mCursor.moveToPosition(position);
// Build the URI
int id = mCursor.getInt(mCursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns._ID));
Uri uri = Uri.withAppendedPath(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + id);
holder.image.setTag(uri);
holder.image.setImageURI(uri);
..again, straightforward. This is code I have cobbled together from dozens of examples, all basically the same. What is it about the EVO that could cause this not to work.
If I remove the query restriction:
// Select only mini's
String selection = MediaStore.Images.Thumbnails.KIND + "=" + MediaStore.Images.Thumbnails.MINI_KIND;
...then it returns almost double the "images" than there are in the Gallery, but most do not have Thumbnail images.
Any ideas?
Upvotes: 0
Views: 744
Reputation: 3570
The SenseUI phones don't all do thumbnails according to the documentation. Some of them only do MICRO_KIND thumbnails - I remember the Incredible doing the same thing. In order to get the image app that I used to work on to work correctly, I had to query both kinds of thumbnails and even sometimes roll my own.
Upvotes: 1