Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will the notification channel importance be overriden by individual notification importance?

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

like image 429
Gaket Avatar asked Jun 28 '18 16:06

Gaket


1 Answers

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.

like image 73
Chee-Yi Avatar answered Sep 20 '22 23:09

Chee-Yi