安卓Notification.Builder:不显示图标的通知 [英] Android Notification.Builder: show a notification without icon

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

问题描述

 String ns = Context.NOTIFICATION_SERVICE;
 NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

 int icon = R.drawable.ic_notification_icon;
 android.app.Notification.Builder nbuilder = new Notification.Builder(this);

 nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName));
 nbuilder.setContentText(msg);
 nbuilder.setOnlyAlertOnce(true);
 nbuilder.setOngoing(true);
 nbuilder.setSmallIcon(icon,level.level);

我怎样可以隐藏或完全删除smallIcon?我试图不使用nbuilder.setSmallIcon,但结果是,通知没有在所有示出!

How can I hide or completely delete the smallIcon? I tried to not use nbuilder.setSmallIcon, but the result is that the notification is not shown at all!

推荐答案

在果冻豆,以后你可以用 nbuilder.setPriority(Notification.PRIORITY_MIN);这个优先级的确切间pretation是留给系统的UI,但在AOSP这会导致通知的图标被隐藏。

On Jelly Bean and later you can use nbuilder.setPriority(Notification.PRIORITY_MIN); the exact interpretation of this priority level is left up to the system UI, but in AOSP this causes the notification's icon to be hidden.

这是为环境或背景的信息,这并不需要得到用户的关注,但如果用户恰好被戳通知面板身边,她可能会感兴趣。看到Android设计网站的通知部分获取更多关于如何最好地使用申报优先。

This is intended for "ambient" or "background" information that doesn't need to get the user's attention, but if the user happens to be poking around the notification panel, she might be interested. See the Notifications section of the Android Design site for more about how to best use notification priority.

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

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