我想在我的应用中创建一堆Android Oreo NotificationChannel
。有些默认为打开,有些默认为关闭。对于三星设备,这很容易:我在想默认关闭的频道上设置了NotificationManager.IMPORTANCE_NONE
。但是,在华为P20 Pro上,这不仅使通道处于启用状态,而且具有最高优先级:发出声音,振动并显示弹出窗口。
如何为华为P20 pro和其他华为设备创建默认关闭的频道?
证据:
代码:
val chan1 = NotificationChannel(
"1",
"None",
NotificationManager.IMPORTANCE_NONE
)
val chan2 = NotificationChannel(
"2",
"Min",
NotificationManager.IMPORTANCE_MIN
)
val chan3 = NotificationChannel(
"3",
"Default",
NotificationManager.IMPORTANCE_DEFAULT
)
val notificationManager: NotificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannels(listOf(chan1, chan2, chan3))
屏幕截图: