4

I'm trying to show a media style notification, and I'm grabbing the image for the art from my app's local files directory by Uri. When the same exact same image is shown in my app (via coil's AsyncImage) it displays in perfect quality, but when the image is shown in the notification, it's horribly pixilated and blurry.

I'm creating the bitmap for the notification using ImageDecoder.decodeBitmap, providing it a source using ImageDecoder.createSource (I've tried both using the content resolver and Uri as a source and using File(Uri.path) as a source, both give the same result).

I then use setLargeIcon providing the bitmap created.

Strangely enough, when I log the bitmap's width and height after being created and before being passed to setLargeIcon, it reports the same dimensions as the original image, so it seems fine before it's passed to the media style notification.

Any ideas?

Joseph Long
  • 241
  • 1
  • 3
  • 12

1 Answers1

0

Please try to use setMetadata() of MediaSessionCompat.

MediaSessionCompat mediasession = new MediaSessionCompat(..);
MediaMetadataCompat.Builder bld = new MediaMetadataCompat.Builder();
//put metadata such as title, artist...
bld.putBitmap(BITMAP_FROM_RESOURCE);
mediaSession.setMetadata(bld.build());

The MediaStyle notification doesn't seem to use the image from setLargeIcon.

toto263
  • 81
  • 5