Google is committed to advancing racial equity for Black communities. See how.

NotificationChannelCompat

open class NotificationChannelCompat
kotlin.Any
   ↳ androidx.core.app.NotificationChannelCompat

A representation of settings that apply to a collection of similarly themed notifications. Setters return this to allow chaining. This class doesn't do anything on older SDKs which don't support Notification Channels.

Summary

Nested classes
open

Builder class for NotificationChannelCompat objects.

Constants
static String

The id of the default channel for an app.

Public methods
open Boolean

Returns whether notifications posted to this channel are allowed to display outside of the notification shade, in a floating window on top of other apps.

open Boolean

Whether or not notifications posted to this channel can bypass the Do Not Disturb android.app.NotificationManager#INTERRUPTION_FILTER_PRIORITY mode.

open Boolean

Returns whether notifications posted to this channel can appear as badges in a Launcher application.

open AudioAttributes?

Returns the audio attributes for sound played by notifications posted to this channel.

open String?

Returns the id of the conversation backing this channel, if it's associated with a conversation.

open String?

Returns the user visible description of this channel.

open String?

Returns what group this channel belongs to.

open String

Returns the id of this channel.

open Int

Returns the user specified importance e.

open Int

Returns the notification light color for notifications posted to this channel.

open Int

Returns whether or not notifications posted to this channel are shown on the lockscreen in full or redacted form.

open CharSequence?

Returns the user visible name of this channel.

open String?

Returns the id of the parent notification channel to this channel, if it's a conversation related channel.

open Uri?

Returns the notification sound for this channel.

open LongArray?

Returns the vibration pattern for notifications posted to this channel.

open Boolean

Whether or not notifications in this conversation are considered important.

open Boolean

Returns whether notifications posted to this channel trigger notification lights.

open Boolean

Returns whether notifications posted to this channel always vibrate.

open NotificationChannelCompat.Builder

Creates a Builder instance with all the writeable property values of this instance.

Constants

DEFAULT_CHANNEL_ID

static val DEFAULT_CHANNEL_ID: String

The id of the default channel for an app. This id is reserved by the system. All notifications posted from apps targeting android.os.Build.VERSION_CODES#N_MR1 or earlier without a notification channel specified are posted to this channel.

Value: "miscellaneous"

Public methods

canBubble

open fun canBubble(): Boolean

Returns whether notifications posted to this channel are allowed to display outside of the notification shade, in a floating window on top of other apps.

This is a read-only property which is only valid on instances fetched from the NotificationManagerCompat.

canBypassDnd

open fun canBypassDnd(): Boolean

Whether or not notifications posted to this channel can bypass the Do Not Disturb android.app.NotificationManager#INTERRUPTION_FILTER_PRIORITY mode.

This is a read-only property which is only valid on instances fetched from the NotificationManagerCompat.

canShowBadge

open fun canShowBadge(): Boolean

Returns whether notifications posted to this channel can appear as badges in a Launcher application. Note that badging may be disabled for other reasons.

getAudioAttributes

@Nullable open fun getAudioAttributes(): AudioAttributes?

Returns the audio attributes for sound played by notifications posted to this channel.

getConversationId

@Nullable open fun getConversationId(): String?

Returns the id of the conversation backing this channel, if it's associated with a conversation. See Builder#setConversationId(String, String).

getDescription

@Nullable open fun getDescription(): String?

Returns the user visible description of this channel.

getGroup

@Nullable open fun getGroup(): String?

Returns what group this channel belongs to. This is used only for visually grouping channels in the UI.

getId

@NonNull open fun getId(): String

Returns the id of this channel.

getImportance

open fun getImportance(): Int

Returns the user specified importance e.g. NotificationManagerCompat#IMPORTANCE_LOW for notifications posted to this channel. Note: This value might be > NotificationManagerCompat#IMPORTANCE_NONE, but notifications posted to this channel will not be shown to the user if the parent NotificationChannelGroup or app is blocked. See NotificationChannelGroup#isBlocked() and NotificationManagerCompat#areNotificationsEnabled().

getLightColor

open fun getLightColor(): Int

Returns the notification light color for notifications posted to this channel. Irrelevant unless shouldShowLights().

getLockscreenVisibility

open fun getLockscreenVisibility(): Int

Returns whether or not notifications posted to this channel are shown on the lockscreen in full or redacted form.

This is a read-only property which is only valid on instances fetched from the NotificationManagerCompat.

getName

@Nullable open fun getName(): CharSequence?

Returns the user visible name of this channel.

getParentChannelId

@Nullable open fun getParentChannelId(): String?

Returns the id of the parent notification channel to this channel, if it's a conversation related channel. See Builder#setConversationId(String, String).

getSound

@Nullable open fun getSound(): Uri?

Returns the notification sound for this channel.

getVibrationPattern

@Nullable open fun getVibrationPattern(): LongArray?

Returns the vibration pattern for notifications posted to this channel. Will be ignored if vibration is not enabled (shouldVibrate().

isImportantConversation

open fun isImportantConversation(): Boolean

Whether or not notifications in this conversation are considered important.

Important conversations may get special visual treatment, and might be able to bypass DND.

This is only valid for channels that represent conversations, that is, those with a valid conversation id.

This is a read-only property which is only valid on instances fetched from the NotificationManagerCompat.

shouldShowLights

open fun shouldShowLights(): Boolean

Returns whether notifications posted to this channel trigger notification lights.

shouldVibrate

open fun shouldVibrate(): Boolean

Returns whether notifications posted to this channel always vibrate.

toBuilder

@NonNull open fun toBuilder(): NotificationChannelCompat.Builder

Creates a Builder instance with all the writeable property values of this instance.