Reputation: 55
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.
Upvotes: 0
Views: 2996
Reputation: 619
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.
Upvotes: 0
Reputation: 69
You have to use icon from res/drawable folder for setSmallIcon().
But in API23, you can use bitmap
setSmallIcon(Icon.createWithBitmap(bitmap))
Upvotes: 1