Home > Blockchain >  How to produce an Icon for the Notification.Action.Builder(...) constructor parameter?
How to produce an Icon for the Notification.Action.Builder(...) constructor parameter?

Time:06-15

Notification.Action.Builder() constructor takes an Icon as input parameter, but I don't know how to produce an Icon? There seems to be no info on that. Old Builder constructor which takes a drawable Int is now deprecated.

public Builder(Icon icon, CharSequence title, PendingIntent intent) {
    throw new RuntimeException("Stub!");
}

CodePudding user response:

The Icon class is an encapsulation class for different kinds of methods to fetch an icon (e.g. bitmap, from file,...)

all (static) methods are listed here

If you want to access an icon by its drawable int, you can do the following:

Icon icon = Icon.createWithResource(context,R.drawable.YOUR_DRAWABLE_REFERENCE);
  • Related