Skip to content

Android Notification Channel — Complete Guide

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about Android Notification Channel. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

Notifications don't show up on Android 8+ because you never created a notification channel, or they show without sound because you set the wrong importance.

Wrong Approach ❌

// No channel — notification won't show on API 26+
val builder = NotificationCompat.Builder(this, "general")
    .setContentTitle("Hello")
    .setContentText("World")
    .setSmallIcon(R.drawable.ic_notification)
// Channel created but wrong importance
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    val channel = NotificationChannel(
        "alerts", "Alerts", NotificationManager.IMPORTANCE_MIN // No sound!
    )
    notificationManager.createNotificationChannel(channel)
}

Output: Notification doesn't appear (no channel) or appears without sound/title.

Right Approach ✅

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        createNotificationChannels()
    }

    private fun createNotificationChannels() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            val notificationManager = getSystemService(NotificationManager::class.java)

            // High importance — makes sound, shows heads-up
            val urgentChannel = NotificationChannel(
                URGENT_CHANNEL_ID,
                "Urgent Alerts",
                NotificationManager.IMPORTANCE_HIGH
            ).apply {
                description = "Time-sensitive notifications"
                enableVibration(true)
                setLightColor(Color.RED)
            }

            // Default importance — shows in shade, no sound
            val defaultChannel = NotificationChannel(
                DEFAULT_CHANNEL_ID,
                "Notifications",
                NotificationManager.IMPORTANCE_DEFAULT
            ).apply {
                description = "General notifications"
            }

            // Low importance — no sound, no heads-up
            val silentChannel = NotificationChannel(
                SILENT_CHANNEL_ID,
                "Silent Updates",
                NotificationManager.IMPORTANCE_LOW
            ).apply {
                description = "Updates without interruption"
                setSound(null, null)
            }

            // Create channel group
            val group = NotificationChannelGroup("social", "Social")
            notificationManager.createNotificationChannelGroup(group)

            notificationManager.createNotificationChannels(
                listOf(urgentChannel, defaultChannel, silentChannel)
            )
        }
    }
}

Output: Notifications show with correct sound, vibration, and appearance.

Prevention

  • Create all channels in Application.onCreate() before posting any notification.
  • Use IMPORTANCE_HIGH for urgent, IMPORTANCE_DEFAULT for normal, IMPORTANCE_LOW for silent.
  • Use channel groups for categorizing related channels.
  • Channel importance cannot be changed programmatically — only by the user.

Common Mistakes with notification channel

  1. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  2. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  3. Misunderstanding that String is [Char] with poor performance for large text operations

These mistakes appear frequently in real-world Android code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why is my notification silent on Android 8+?

You need IMPORTANCE_HIGH for sound and heads-up display. IMPORTANCE_DEFAULT shows in the shade but doesn't make a sound by default on many devices.

### Can I change a channel's importance after creation?

No. Once created, only the user can change the channel settings via system Settings. Delete and recreate the channel (requires app reinstall) or create a new channel.

### What is the maximum number of channels?

Android has no hard limit, but 3-5 well-named channels are recommended for good UX. Each channel should represent a distinct notification type.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro