Android Album Thumbnail einstellen

Ich habe einige Coverbilder für ein Album abgerufen (ich habe die ID und eine Bitmap) und möchte sie jetzt in den MediaStore stellen.

Ich habe ein paar Sachen ausprobiert:

private static final Uri ARTWORK_URI = Uri.parse("content://media/external/audio/albumart");

public static void writeArtwork(Context context, Bitmap bmp, int albumId) {
        ContentResolver res = context.getContentResolver();
        Uri uri = ContentUris.withAppendedId(ARTWORK_URI, albumId);
        LogUtil.i(TAG, "uri= " + uri);
        if (uri != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bmp.compress(Bitmap.CompressFormat.JPEG, 50, baos);
            byte[] bytes = baos.toByteArray();
            LogUtil.i(TAG, "Bytes: " + bytes.length);
            ContentValues values = new ContentValues();
            values.put("album_id", albumId);
            values.put("_data", bytes);
            res.insert(uri, values);
        }
    }

Dies gibt java.lang.UnsupportedOperationException: Ungültiger URI-Inhalt: // media / external / audio / albumart / 5

Auch ich habe versucht:

Uri artworkUri = Uri.parse("content://media/external/audio/albumart");
Uri uri = ContentUris.withAppendedId(artworkUri, album.getId());
OutputStream outStream = getContentResolver().openOutputStream(uri);
bmp.compress(Bitmap.CompressFormat.JPEG, 50, outStream);

Aber dies gibt FileNotFoundException.

Antworten auf die Frage(0)

Ihre Antwort auf die Frage