开发者

Using custom drawables in an Android Notification

开发者 https://www.devze.com 2022-12-17 03:40 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消