Android notification channels: keeping critical alerts audible while silencing routine ones
0 reputation · 17 Dec 2021, 05:24 UTC
0 reputation · 17 Dec 2021, 05:24 UTC
I manage an Android app targeting API 26+ that posts several notification types: time-critical alerts (e.g., security events) and routine updates (e.g., daily summaries). I want users to be able to silence the routine updates without losing the critical alerts, and I want the defaults to be sensible so users do not have to configure everything manually.
I have created separate notification channels per category, but the behavior I see is unclear in two areas. First, when a channel's importance is set to high, the system plays sound and may peek on screen, but I am unsure how that interacts with Do Not Disturb: does a high-importance channel automatically bypass DND, or does the user have to explicitly allow the channel as an exception? Second, once a user has changed a channel's settings, my understanding is the app can no longer programmatically adjust that channel's importance or sound, which makes me question how to handle a channel I created with the wrong initial importance.
Assume Android 8.0 (API 26) through recent versions, with awareness that manufacturer skins may alter the channel UI.
1. Does channel importance alone determine DND behavior, or is a separate per-channel DND override required from the user?
2. Is deleting and recreating a channel with a new ID the only supported way to change defaults after user modification?
3. Is there a documented way to deep-link users directly to a specific channel's settings screen?
35275 reputation · 17 Dec 2021, 16:54 UTC
1. Channel importance alone does not bypass Do Not Disturb (DND). To make a notification audible while DND is active you must either mark it as a priority notification (via setPriority(PRIORITY_HIGH) on the builder) **and** have the user allow the channel as a DND exception, or you must call setBypassDnd(true) on the notification (or channel on API 28+) **and** have the special "Do Not Disturb access" permission granted to your app.
2. After a user manually changes a channel’s importance, sound, or other settings, the system locks those values. Your app cannot override them by calling NotificationManager.createNotificationChannel again. The only supported way to change the default behavior is to create a **new** channel with a different ID; deleting and recreating a channel with the same ID will discard the user’s customizations, which is usually not desirable.
3. Yes. Launch an intent with action Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS and include the extras EXTRA_CHANNEL_ID (your channel’s ID) and EXTRA_APP_PACKAGE (your package name). Optionally add EXTRA_APP_OP for a direct jump to the channel’s settings screen.
NotificationChannel.setBypassDnd(true); on API 26‑27 you must use Notification.Builder.setBypassDnd(true) when building the notification.Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS with EXTRA_CHANNEL_ID opens the channel‑specific settings screen.POST_NOTIFICATIONS permission; without it notifications (and channel creation) are silently dropped.CRITICAL_CHANNEL with IMPORTANCE_HIGH and setBypassDnd(true) (or builder flag) and request the DND access special permission if you want it to sound during DND.ROUTINE_CHANNEL with IMPORTANCE_LOW or DEFAULT and setBypassDnd(false); users can silence it via system settings.NotificationManager.isNotificationPolicyAccessGranted()) and, if not, direct the user to Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS to grant it.Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS); intent.putExtra(Settings.EXTRA_CHANNEL_ID, CRITICAL_CHANNEL_ID); intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()); startActivity(intent);Do you have the app granted the Do Not Disturb access special permission? If not, the critical channel will not bypass DND even with setBypassDnd(true), and you’ll need to request that permission before the bypass works.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.