Jeremy Logan
Jeremy Logan

Reputation: 47514

Using custom drawables in an Android Notification

Is there any way to use an image that I'm generating on the fly as a Notification icon?

Upvotes: 4

Views: 6532

Answers (3)

Mark B
Mark B

Reputation: 200657

Try creating a custom Notifications view, then you should be able to use a Bitmap object:

RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.custom_notification_layout);
contentView.setImageViewBitmap(R.id.icon_view, myBitmapObject);
notification.contentView = contentView;

For more info see "Creating a Custom Expanded View" on this page: https://developer.android.com/guide/topics/ui/notifiers/notifications.html

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006869

This topic was discussed in a previous SO question. Upshot: I don't think it is possible.

UPDATE: For tablets or other large-screen devices, on API Level 11+, there is a largeIcon property which accepts a Bitmap. AFAIK, this is unused on smaller-screen devices, such as phones.

Upvotes: 2

kenyu73
kenyu73

Reputation: 681

You can now change the main icon with API 11 (Notification.Builder -> setLargeIcon)

Upvotes: 2

Related Questions