I've made an image gallery activity that is needed for my app. All works well except that it shows an image album for every music album I have in my SD card that contains album art. The default gallery app manages to hide these albums-pictures. How can I achieve the same ?
I get image albums with this code:
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = { MediaStore.Images.Media._ID, MediaStore.Images.Media.BUCKET_ID,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME,MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
ArrayList<String> ids = new ArrayList<String>();
if (cursor != null) {
while (cursor.moveToNext()) {
PhotoAlbum album = new PhotoAlbum();
int columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID);
album.id = cursor.getString(columnIndex);
if (!ids.contains(album.id)) {
//get album name
columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
album.name = cursor.getString(columnIndex);
//get image id for the album cover
columnIndex = cursor.getColumnIndex(MediaStore.Images.Media._ID);
album.coverID = cursor.getInt(columnIndex);
//get filename of album cover image
columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
album.fileName=new File(cursor.getString(columnIndex)).getParentFile().getAbsolutePath();
album.count++; albumList.add(album); ids.add(album.id); album.bm=null;
} else { albumList.get(ids.indexOf(album.id)).count++; }
}
cursor.close();
}