How can I know programmatically if a notification channel is enabled on Android O?

The Official Documentation has your answer:

You can call the following two methods to discover the settings a user has applied to a notification channel:

  • o retrieve a single notification channel, you can call getNotificationChannel().
  • To retrieve all notification channels belonging to your app, you can call getNotificationChannels().

After you have the NotificationChannel, you can use methods such as getVibrationPattern() and getSound() to find out what settings the user currently has. To find out if a user blocked a notification channel, you can call getImportance(). If the notification channel is blocked, getImportance() returns IMPORTANCE_NONE.

So getImportance() will tell you if notification channel is blocked or not.

Tags:

Android