3

After updating on Android R, my app can't loading albums' art.
Code below working on Android Q

Uri uri = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, albumId);
Size size = new Size(700, 700);

return contentResolver.loadThumbnail(uri, size, null);

And also code below working on Android P and earlier

private Bitmap getAlbumArt(int albumId) {
    try (Cursor cursor = contentResolver.query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
            new String[]{MediaStore.Audio.AlbumColumns.ALBUM_ART},
            _ID + "=?",
            new String[]{String.valueOf(albumId)},
            null)) {

        if (cursor == null || !cursor.moveToFirst()) {
            return null;
        }
        String artLink = cursor.getString(0);
        return BitmapFactory.decodeFile(artLink);
    }
}

The problem is that there is no information in documentation about extracting album art. After updates file storage access policy this is not working.

  • Check this answer it will work https://stackoverflow.com/questions/66077161/android-loadthumbnail-album-artwork-api-29/68064437#68064437 – satishprattipati Jun 21 '21 at 12:14

1 Answers1

-1

Seems it was deprecated. Look there

borune
  • 548
  • 5
  • 21