Before Android O, users could silence an app's notifications entirely or not at all. There was no way to mute promotional alerts while keeping order updates loud, for example. Notification Channels fix that by letting developers group notifications into categories that users can configure independently.
Once a channel is created, users can adjust its importance, sound, vibration, lock screen visibility, and Do Not Disturb behaviour directly from system settings — without affecting any other channel from the same app.
## Creating a Channel
A NotificationChannel takes three arguments: a unique channel ID, a user-visible name, and an importance level. Create it through NotificationManager:
NotificationChannel channel_1 = new NotificationChannel(
"sports",
"Sports",
NotificationManager.IMPORTANCE_DEFAULT
);
channel_1.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel_1);
The channel ID ("sports" here) must be unique within the app — it's what ties a notification to its channel. You can create multiple channels for different notification types:
NotificationChannel channel_2 = new NotificationChannel(
"finance",
"Finance",
NotificationManager.IMPORTANCE_HIGH
);
manager.createNotificationChannel(channel_2);
Tip
Creating a channel that already exists is a no-op, so it's safe to call this on every app launch.
## Assigning a Notification to a Channel
Pass the channel ID to Notification.Builder:
Notification.Builder builder = new Notification.Builder(getApplicationContext(), "sports")
.setContentTitle("Sports")
.setContentText("India V/s New Zealand match postponed due to rain")
.setSmallIcon(R.drawable.ic_launcher_background)
.setChannelId("sports")
.setAutoCancel(true);
Important
On Android O and above, a notification without a valid channel ID will not be delivered. On older API levels the channel ID is ignored, so the same code works across versions.
## What Users Can Configure Per Channel
Once a channel exists, users can modify the following from Settings → App → Notifications:
- Importance — controls how interruptive the notification is (sound, heads-up, etc.)
- Sound — the notification tone for this category
- Vibration — on or off
- Blink light — LED colour and pattern
- Lock screen — show all content, hide sensitive content, or don't show
- Do Not Disturb — whether this channel can override DND
Note
The app can set these defaults when creating the channel, but the user's choices after that point take precedence and cannot be overridden programmatically.
The full sample is on GitHub.