Nil*_*zor 7 android push-notification android-8.0-oreo
I want to create a bunch of Android Oreo NotificationChannels in my app. Some default to on, some to off. For Samsung devices this was easy: I set NotificationManager.IMPORTANCE_NONE on the channels I wanted to be off by default. On a Huawei P20 Pro however, this makes the channels not only enabled but with the highest priority: Making sound, vibrates and displays a popup.
How can I create a channel that is off by default for Huawei P20 pro and other Huawei devices?
Evidence:
Code:
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))
Run Code Online (Sandbox Code Playgroud)
Screenshot:
| 归档时间: |
|
| 查看次数: |
61 次 |
| 最近记录: |