android - 如何设置动态小图标通知

标签 android notifications android-notifications android-statusbar

如何在状态栏设置动态小图标通知? Notification.Builder.setSmallIcon(int icon) 此代码从资源中设置静态图标。需要动态设置图标

示例

enter image description here

图标温度动态变化

请帮忙。

最佳答案

只需创建一个带有新图标的新通知在创建通知时使用相同的 ID。 它将替换旧通知并因此更改通知中的图像。

如果你不想在你的可绘制文件夹中有这么多图标。创建 BitmapDrawable来自字符串,然后将其设置为 smallIcon。

关于android - 如何设置动态小图标通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34576106/

相关文章:

android - 转储的 XML 布局文件填充位置行为不正确

安卓 2.1 : How to zoom in/out and scroll on a GridView

PHP通知

Android 到 PC 通知平台

android - 如何从文本按钮中删除填充?

java - 如何在 Assets 中运行可执行文件?

ios - 根据通知数量增加角标(Badge)值

android - 在收到 gcm 通知时显示多个通知

android - 如何检测通知id是否存在?

android - 显示来自多个通知的消息-Android