![](/img/trans.png)
[英]Android: How to adjust the largeIcon of a NotificationCompat.Builder in the bounds of the notification
[英]Android how to hide NotificationCompat.Builder notification`s icon on status bar?
我的问题很简单,但我无法解决它很长一段时间,所以我在这里问。
如何隐藏状态栏中显示的正在进行的通知图标? 我正在使用NotificationCompat.Builder
对象创建通知。 我试图跳过(当取消选中显示图标的选项时) builder.setSmallIcon()
函数调用,但这导致通知屏幕上没有通知。
从Android 4.1(API 16)开始,可以指定通知的priority
。 如果将该标志设置为PRIORITY_MIN
,通知图标将不会显示在状态栏上。
builder.setPriority(NotificationCompat.PRIORITY_MIN);
从Android 8.0 Oreo(API级别26)开始,您必须创建NotificationChannel
并将其importance
设置为IMPORTANCE_MIN
:
NotificationChannel channel =
new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_MIN);
notificationManager.createNotificationChannel(channel);
...
builder.setChannelId(channel.getId());
如何隐藏状态栏中显示的正在进行的通知图标?
你没有。
我试图跳过(当取消选中显示图标的选项时)builder.setSmallIcon()函数调用,但这导致通知屏幕中没有通知。
正确。 由于提出Notification
的主要目的是在状态栏中放置一个图标,因此无法在状态栏中放置图标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.