安卓:对于通知无图标 [英] Android: No icon for Notification

查看:170
本文介绍了安卓:对于通知无图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创造一个通知,而不在状态栏(即没有展开的状态)的图标。我想自定义扩展的查看和设置的图标,仅此观点。但没有奏效。当我给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;

<一个href="http://$c$c.google.com/p/quick-settings/source/browse/trunk/quick-settings/src/com/bwx/bequick/receivers/StatusBarIntegrationReceiver.java" rel="nofollow">http://$c$c.google.com/p/quick-settings/source/browse/trunk/quick-settings/src/com/bwx/bequick/receivers/StatusBarIntegrationReceiver.java

这篇关于安卓:对于通知无图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆