NotificationChannelCompat

Added in 1.5.0

public class 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 types

Builder class for NotificationChannelCompat objects.

Constants

static final String
DEFAULT_CHANNEL_ID = "miscellaneous"

The id of the default channel for an app.

Public methods

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.

boolean

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

boolean

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

@Nullable AudioAttributes

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

@Nullable String

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

@Nullable String

Returns the user visible description of this channel.

@Nullable String

Returns what group this channel belongs to.

@NonNull String

Returns the id of this channel.

int

Returns the user specified importance e.g. IMPORTANCE_LOW for notifications posted to this channel.

int

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

int

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

@Nullable CharSequence

Returns the user visible name of this channel.

@Nullable String

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

@Nullable Uri

Returns the notification sound for this channel.

@Nullable long[]

Returns the vibration pattern for notifications posted to this channel.

boolean

Whether or not notifications in this conversation are considered important.

boolean

Returns whether notifications posted to this channel trigger notification lights.

boolean

Returns whether notifications posted to this channel always vibrate.

@NonNull NotificationChannelCompat.Builder

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

Constants

DEFAULT_CHANNEL_ID

Added in 1.5.0
public static final String DEFAULT_CHANNEL_ID = "miscellaneous"

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

Public methods

canBubble

Added in 1.5.0
public boolean canBubble()

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

Added in 1.5.0
public boolean canBypassDnd()

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

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

canShowBadge

Added in 1.5.0
public boolean canShowBadge()

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

Added in 1.5.0
public @Nullable AudioAttributes getAudioAttributes()

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

getConversationId

Added in 1.5.0
public @Nullable String getConversationId()

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

getDescription

Added in 1.5.0
public @Nullable String getDescription()

Returns the user visible description of this channel.

getGroup

Added in 1.5.0
public @Nullable String getGroup()

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

getId

Added in 1.5.0
public @NonNull String getId()

Returns the id of this channel.

getImportance

Added in 1.5.0
public int getImportance()

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

getLightColor

Added in 1.5.0
public int getLightColor()

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

getLockscreenVisibility

Added in 1.5.0
public int getLockscreenVisibility()

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

Added in 1.5.0
public @Nullable CharSequence getName()

Returns the user visible name of this channel.

getParentChannelId

Added in 1.5.0
public @Nullable String getParentChannelId()

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

getSound

Added in 1.5.0
public @Nullable Uri getSound()

Returns the notification sound for this channel.

getVibrationPattern

Added in 1.5.0
public @Nullable long[] getVibrationPattern()

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

isImportantConversation

Added in 1.5.0
public boolean isImportantConversation()

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

Added in 1.5.0
public boolean shouldShowLights()

Returns whether notifications posted to this channel trigger notification lights.

shouldVibrate

Added in 1.5.0
public boolean shouldVibrate()

Returns whether notifications posted to this channel always vibrate.

toBuilder

Added in 1.5.0
public @NonNull NotificationChannelCompat.Builder toBuilder()

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