Q:

custom notification use programmatically generated drawables

I was trying to implement custom notifications in android.
Basically, i have a music player application and i am trying to set a custom notification for the app.
app:minimum:16&maximum:26; 
    RemoteViews contentView=new RemoteViews(getPackageName(),R.layout.custom_notification);
    Bitmap bm=BitmapFactory.decodeFile(songImage);
    Drawable drawable=new BitmapDrawable(getResources(),bm);
    contentView.setImageViewResource(R.id.notificationIcon,drawable);

This is what i did, for every image i want the icon to replaced by its album art.
Everything is fine until the last line in the above code.
setImageViewResource takes two arguments  first one being the element id and the second being the drawable id.
But the problem is that , i am generating drawables depending on the song which has to drawn programmatically.
How can i use this method or set the album art for the corresponding image view?
Custom Notification.xml
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:padding="10dp">
    <ImageView
        android:layout_width="50dp"
        android:layout_height="match_parent"
        android:background="@drawable/playicon"
        android:id="@+id/notificationIcon"
        android:layout_marginRight="10dp"
        android:layout_marginEnd="10dp" />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="150dp"
        android:layout_height="match_parent">
        <TextView
            android:textSize="15sp"
            android:textColor="#000"

            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            />
        <TextView
            android:textSize="13sp"
            android:textColor="#000"
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            />
    </LinearLayout>
    <Button
        android:layout_width="40dp"
        android:layout_height="match_parent"
        android:id="@+id/notificationPrev"
        android:background="@drawable/back"
        />
    <Button
        android:layout_width="40dp"
        android:layout_height="match_parent"
        android:id="@+id/notificationPlay"
        android:background="@drawable/smallpause"
        />
    <Button
        android:layout_width="40dp"
        android:layout_height="match_parent"
        android:id="@+id/notificationForw"
        android:background="@drawable/forw"
        />

</LinearLayout>

A:

Instead of using setImageViewResource() you can use setImageViewBitmap() here you can load which ever bitmap you want.

