public class

NotificationChannelCompat.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.core.app.NotificationChannelCompat.Builder

Overview

Builder class for NotificationChannelCompat objects.

Summary

Constructors
publicBuilder(java.lang.String id, int importance)

Creates a notification channel builder.

Methods
public NotificationChannelCompatbuild()

Creates a NotificationChannelCompat instance.

public NotificationChannelCompat.BuildersetConversationId(java.lang.String parentChannelId, java.lang.String conversationId)

Sets this channel as being conversation-centric.

public NotificationChannelCompat.BuildersetDescription(java.lang.String description)

Sets the user visible description of this channel.

public NotificationChannelCompat.BuildersetGroup(java.lang.String groupId)

Sets what group this channel belongs to.

public NotificationChannelCompat.BuildersetImportance(int importance)

Sets the level of interruption of this notification channel.

public NotificationChannelCompat.BuildersetLightColor(int argb)

Sets the notification light color for notifications posted to this channel, if lights are enabled on this channel and the device supports that feature.

public NotificationChannelCompat.BuildersetLightsEnabled(boolean lights)

Sets whether notifications posted to this channel should display notification lights, on devices that support that feature.

public NotificationChannelCompat.BuildersetName(java.lang.CharSequence name)

Sets the user visible name of this channel.

public NotificationChannelCompat.BuildersetShowBadge(boolean showBadge)

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

public NotificationChannelCompat.BuildersetSound(Uri sound, AudioAttributes audioAttributes)

Sets the sound that should be played for notifications posted to this channel and its audio attributes.

public NotificationChannelCompat.BuildersetVibrationEnabled(boolean vibration)

Sets whether notification posted to this channel should vibrate.

public NotificationChannelCompat.BuildersetVibrationPattern(long[] vibrationPattern[])

Sets the vibration pattern for notifications posted to this channel.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(java.lang.String id, int importance)

Creates a notification channel builder.

Parameters:

id: The id of the channel. Must be unique per package. The value may be truncated if it is too long.
importance: The importance of the channel. This controls how interruptive notifications posted to this channel are.

Methods

public NotificationChannelCompat.Builder setName(java.lang.CharSequence name)

Sets the user visible name of this channel. You can rename this channel when the system locale changes by listening for the broadcast.

The recommended maximum length is 40 characters; the value may be truncated if it is too long.

public NotificationChannelCompat.Builder setImportance(int importance)

Sets the level of interruption of this notification channel. Only modifiable before the channel is submitted to NotificationManagerCompat.

Parameters:

importance: the amount the user should be interrupted by notifications from this channel.

public NotificationChannelCompat.Builder setDescription(java.lang.String description)

Sets the user visible description of this channel.

The recommended maximum length is 300 characters; the value may be truncated if it is too long.

public NotificationChannelCompat.Builder setGroup(java.lang.String groupId)

Sets what group this channel belongs to. Group information is only used for presentation, not for behavior. Only modifiable before the channel is submitted to NotificationManagerCompat, unless the channel is not currently part of a group.

Parameters:

groupId: the id of a group created by NotificationManagerCompat.createNotificationChannelGroup(NotificationChannelGroup).

public NotificationChannelCompat.Builder setShowBadge(boolean showBadge)

Sets whether notifications posted to this channel can appear as application icon badges in a Launcher. Only modifiable before the channel is submitted to NotificationManagerCompat.

Parameters:

showBadge: true if badges should be allowed to be shown.

public NotificationChannelCompat.Builder setSound(Uri sound, AudioAttributes audioAttributes)

Sets the sound that should be played for notifications posted to this channel and its audio attributes. Notification channels with an NotificationChannelCompat.Builder.setImportance(int) importance} of at least NotificationManagerCompat.IMPORTANCE_DEFAULT should have a sound. Only modifiable before the channel is submitted to NotificationManagerCompat.

public NotificationChannelCompat.Builder setLightsEnabled(boolean lights)

Sets whether notifications posted to this channel should display notification lights, on devices that support that feature. Only modifiable before the channel is submitted to NotificationManagerCompat.

public NotificationChannelCompat.Builder setLightColor(int argb)

Sets the notification light color for notifications posted to this channel, if lights are enabled on this channel and the device supports that feature. Only modifiable before the channel is submitted to NotificationManagerCompat.

public NotificationChannelCompat.Builder setVibrationEnabled(boolean vibration)

Sets whether notification posted to this channel should vibrate. The vibration pattern can be set with NotificationChannelCompat.Builder.setVibrationPattern(long[]). Only modifiable before the channel is submitted to NotificationManagerCompat.

public NotificationChannelCompat.Builder setVibrationPattern(long[] vibrationPattern[])

Sets the vibration pattern for notifications posted to this channel. If the provided pattern is valid (non-null, non-empty), will NotificationChannelCompat.Builder.setVibrationEnabled(boolean) enable vibration} as well. Otherwise, vibration will be disabled. Only modifiable before the channel is submitted to NotificationManagerCompat.

public NotificationChannelCompat.Builder setConversationId(java.lang.String parentChannelId, java.lang.String conversationId)

Sets this channel as being conversation-centric. Different settings and functionality may be exposed for conversation-centric channels. Calling this on SDKs that do not support conversations will have no effect on the built channel. As a result, this channel will not be linked to the channel with the parentChannelId. That means that this channel must be published to directly to be used; it cannot be published to by publishing to the parentChannelId with the shortcutId.

Parameters:

parentChannelId: The NotificationChannelCompat.getId() id} of the generic channel that notifications of this type would be posted to in absence of a specific conversation id. For example, if this channel represents 'Messages from Person A', the parent channel would be 'Messages.'
conversationId: The ShortcutInfoCompat.getId() of the shortcut representing this channel's conversation.

Creates a NotificationChannelCompat instance.