aph*_*ion 3 icons android android-notifications android-statusbar
我的问题很简单,但我无法解决它很长一段时间,所以我在这里问.
如何隐藏状态栏中显示的正在进行的通知图标?我正在用NotificationCompat.Builder对象创建通知.我试图跳过(当取消选中显示图标的选项时)builder.setSmallIcon()函数调用,但这导致通知屏幕上没有通知.
Flo*_*ern 13
从Android 4.1(API 16)开始,就可以指定通知了priority.如果您将该标志设置PRIORITY_MIN为通知图标将不会显示在状态栏上.
builder.setPriority(NotificationCompat.PRIORITY_MIN);
Run Code Online (Sandbox Code Playgroud)
从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());
Run Code Online (Sandbox Code Playgroud)
如何隐藏状态栏中显示的正在进行的通知图标?
你不知道。
我尝试跳过(当未选中显示图标的选项时)builder.setSmallIcon() 函数调用,但这导致通知屏幕中没有通知。
正确的。既然提a的首要目的Notification是在状态栏中放一个图标,那么没有办法不在状态栏中放一个图标。
| 归档时间: |
|
| 查看次数: |
2982 次 |
| 最近记录: |