安卓:对于通知无图标

编程入门 行业动态 更新时间:2024-10-20 20:31:31
本文介绍了安卓:对于通知无图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想创造一个通知,而不在状态栏(即没有展开的状态)的图标。我想自定义扩展的查看和设置的图标,仅此观点。但没有奏效。当我给0作为图标的构造函数,该图标消失,但通知也没有出现在扩展视图。

I wanted to create a notification without the icon in the status bar (the state that is not expanded). I tried the custom expanded view and set the icon for this view only. But it did not work. When I give 0 as icon to the constructor, the icon disappears but notification also does not appear in the expanded view.

的通知的通知=新通知(0,,0);。

Notification notification = new Notification(0, "", 0);

我试了很多组合,但并没有拿出一个解决方案。顺便说一句,我知道这是工作,因为我看到了一些应用程序这个功能。谢谢你。

I tried a lot of combinations but didn't come out with a solution. By the way, I know it is working because I saw this feature in some apps. Thanks.

推荐答案

QuickSettings这样做,当我看着那个code,我看到它使用的通知的默认构造函数,并推动其图标,通知栏的右侧。我认为它仍然使用空间,但没有图标。

QuickSettings did this and as I looked at that code I saw it uses the default constructor of Notification and pushes its icon to the right of the notification bar. I think it still uses space but has no icon.

有些code:

notification = new Notification(); notification.flags |= Notification.FLAG_ONGOING_EVENT; notification.flags |= Notification.FLAG_NO_CLEAR; long hiddenTime = Constants.SDK_VERSION >= 9 ? -Long.MAX_VALUE : Long.MAX_VALUE; notification.when = visible ? System.currentTimeMillis() : hiddenTime; // align // left (0) / right (max) in status bar

编辑:哦,对不起,我错过了code的重要防线,其实他用一个占位符。但是,现在你有一些code, - )

edit: oh sorry I missed an important line of code, in fact he uses a placeholder. But now you have some code ;-)

notification.icon = visible ? (status == Constants.STATUS_BLACK_ICON ? R.drawable.ic_logo_black : R.drawable.ic_logo_white) : R.drawable.ic_placeholder;

$c$c.google/p/quick-settings/source/browse/trunk/quick-settings/src/com/bwx/bequick/receivers/StatusBarIntegrationReceiver.java

更多推荐

安卓:对于通知无图标

本文发布于:2023-11-27 08:06:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637211.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图标   通知

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!