【问题标题】:Is it possible to use an external image as notification icon?是否可以使用外部图像作为通知图标?
【发布时间】:2011-06-27 06:43:20
【问题描述】:

我想让用户可以选择 sdcard 中的外部图像作为通知图标。但是,这似乎是不可能的,只能使用带有资源 id 的内部图像作为通知图标。

因此,我可能需要一种将位图设置为通知图标的方法。

通知示例,只有资源id可以设置为通知图标而不是位图。

int icon = R.drawable.notification_icon; CharSequence tickerText = "你好"; long when = System.currentTimeMillis(); 通知通知 = new Notification(icon,tickerText,when);

另外,我知道通知的自定义扩展视图可以使用外部图像,但它仍然不能用于通知图标。

赞赏。

【问题讨论】:

    标签: android


    【解决方案1】:

    您可以在图标的参考 ID 中提供您的图像 ID 以显示为图像。我个人在自定义和非客户通知中都这样做了

    【讨论】:

    • 谢谢,您能否详细说明如何将资源 id 赋予 sdcard 中的外部图像?
    • hmm...我现在不能给出代码,但可以给出一个想法,您可以针对位图生成 UUID,然后可以将其作为 int 引用
    • 您能提供一些提示吗?顺便说一句,我可以从市场上下载您的应用程序进行测试吗?谢谢。
    【解决方案2】:

    我只是回顾了我最喜欢的问题,似乎这个特殊问题已经在 4.+ 这是一个解决方案: Android - use external profile image in notification bar like Facebook

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-19
      • 1970-01-01
      相关资源
      最近更新 更多