Mer*_*yth 12 icons android android-notifications android-statusbar
我想知道如何创建一个不在状态栏中显示图标的通知.
有一种方法可以隐藏它吗?
Flo*_*ern 32
从Android 4.1(API级别16)开始,就可以指定通知了priority.如果您将该标志设置PRIORITY_MIN为通知图标将不会显示在状态栏上.
notification.priority = Notification.PRIORITY_MIN;
Run Code Online (Sandbox Code Playgroud)
或者如果你使用Notification.Builder:
builder.setPriority(Notification.PRIORITY_MIN);
Run Code Online (Sandbox Code Playgroud)
从Android 8.0 Oreo(API级别26)开始,您必须importance将通知设置NotificationChannel为IMPORTANCE_MIN:
NotificationChannel channel =
new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_MIN);
notificationManager.createNotificationChannel(channel);
...
builder.setChannelId(channel.getId())
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7422 次 |
| 最近记录: |