Is there any way to use an image that开发者_运维百科 I'm generating on the fly as a Notification icon?
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.
You can now change the main icon with API 11 (Notification.Builder -> setLargeIcon)
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
精彩评论