The question is for Android O and above.
For example, I created a notification channel called "default" and set it IMPORTANCE_DEFAULT
. Then I've created a notification, added it to the channel and put IMPORTANCE_HIGH
in its builder. What will be the final priority of the notification?
I didn't find the answer in docs, they say that individual ones are required to support older versions:
To support devices running Android 7.1 (API level 25) or lower, you must also call setPriority() for each notification, using a priority constant from the NotificationCompat class.
https://developer.android.com/training/notify-user/channels#importance
In my experience, on Android O and above, NotificationChannel's importance seems to take precedence over individual Notifications' priority levels.
In my own app I manually specify each Notification's priority levels as well to conform to Google's advice that you quoted. I just tried setting a Notification's priority to PRIORITY_MAX
and send it out via a NotificationChannel with importance IMPORTANCE_DEFAULT
and the notification appeared in the status bar without sliding down (like a heads-up display) like the case when you use a NotificationChannel with IMPORTANCE_HIGH
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With