0

Hi i have a generated merged bitmap and need to set it in Android Notification SmallIcon, how i can do this?

If i try use bitmap like drawable icon i get error.

Bitmap bitmap = dynamicIcon.merge();
builder.setSmallIcon(bitmap);

Thanks.

2 Answers2

1

You have to use icon from res/drawable folder for setSmallIcon().

But in API23, you can use bitmap

    setSmallIcon(Icon.createWithBitmap(bitmap))
tofa
  • 59
  • 1
  • 8
0

Setting bitmap as small icon is available from android M and cannot be used in lower versions.

first you have to check if version is above M or not.

if it's bellow you should use NotificationCompat.Buidler

if it's above android M you should use Notification.Builder

in Notification.Buidler you have a method called setSmallIcon(Icon) that can be uses like this.

builder.setSmallIcon(Icon.createFromBitmap(bitmap));

so if you really need this feature& you only can use it in api level 26 and above.

Shayan D
  • 620
  • 3
  • 14