You need to use loadDrawable
or loadDrawableAsync
on the icon it will return a drawable.
loadDrawable
added in API level 23 public Drawable loadDrawable
(Context context)
Returns a Drawable
that can be used to draw the
image inside this Icon, constructing it if necessary. Depending on the
type of image, this may not be something you want to do on the UI
thread, so consider using loadDrawableAsync instead.
as shown below
Icon icon = notification.getSmallIcon();
Bitmap bitmap = icon.loadDrawable(context);
then you can convert the drawable to bitmap from the stackoverflow link below
there are many answers how to convert drawable to Bitmap
How to convert a Drawable to a Bitmap?