【问题标题】:How set dynamically small icon notification如何动态设置小图标通知
【发布时间】:2016-01-03 11:40:30
【问题描述】:

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

示例

图标温度动态变化

请帮忙。

【问题讨论】:

    标签: android notifications android-notifications android-statusbar


    【解决方案1】:

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

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

    【讨论】:

    • 感谢 BitmapDrawable
    • 这符合您的目的吗?
    • 不要。因为 setSmallIcon 使用的是 int 图标,而不是位图
    猜你喜欢
    • 1970-01-01
    • 2019-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多