NotificationChannelCompat.Builder
public class NotificationChannelCompat.Builder
Builder class for NotificationChannelCompat objects.
Summary
Public constructors |
|---|
|
Creates a notification channel builder. |
Public methods |
|
|---|---|
@NonNull NotificationChannelCompat |
build()Creates a |
@NonNull NotificationChannelCompat.Builder |
setConversationId(Sets this channel as being conversation-centric. |
@NonNull NotificationChannelCompat.Builder |
setDescription(@Nullable String description)Sets the user visible description of this channel. |
@NonNull NotificationChannelCompat.Builder |
Sets what group this channel belongs to. |
@NonNull NotificationChannelCompat.Builder |
setImportance(int importance)Sets the level of interruption of this notification channel. |
@NonNull NotificationChannelCompat.Builder |
setLightColor(int argb)Sets the notification light color for notifications posted to this channel, if lights are |
@NonNull NotificationChannelCompat.Builder |
setLightsEnabled(boolean lights)Sets whether notifications posted to this channel should display notification lights, on devices that support that feature. |
@NonNull NotificationChannelCompat.Builder |
setName(@Nullable CharSequence name)Sets the user visible name of this channel. |
@NonNull NotificationChannelCompat.Builder |
setShowBadge(boolean showBadge)Sets whether notifications posted to this channel can appear as application icon badges in a Launcher. |
@NonNull NotificationChannelCompat.Builder |
setSound(@Nullable Uri sound, @Nullable AudioAttributes audioAttributes)Sets the sound that should be played for notifications posted to this channel and its audio attributes. |
@NonNull NotificationChannelCompat.Builder |
setVibrationEnabled(boolean vibration)Sets whether notification posted to this channel should vibrate. |
@NonNull NotificationChannelCompat.Builder |
setVibrationPattern(@Nullable long[] vibrationPattern)Sets the vibration pattern for notifications posted to this channel. |
Public constructors
Public methods
build
public @NonNull NotificationChannelCompat build()
Creates a NotificationChannelCompat instance.
setConversationId
public @NonNull NotificationChannelCompat.Builder setConversationId(
@NonNull String parentChannelId,
@NonNull 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 | |
|---|---|
@NonNull String parentChannelId |
The |
@NonNull String conversationId |
The |
setDescription
public @NonNull NotificationChannelCompat.Builder setDescription(@Nullable 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.
setGroup
public @NonNull NotificationChannelCompat.Builder setGroup(@Nullable 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 createNotificationChannel, unless the channel is not currently part of a group.
setImportance
public @NonNull NotificationChannelCompat.Builder setImportance(int importance)
Sets the level of interruption of this notification channel. Only modifiable before the channel is submitted to createNotificationChannel.
| Parameters | |
|---|---|
int importance |
the amount the user should be interrupted by notifications from this channel. |
setLightColor
public @NonNull 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 createNotificationChannel.
setLightsEnabled
public @NonNull 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 createNotificationChannel.
setName
public @NonNull NotificationChannelCompat.Builder setName(@Nullable CharSequence name)
Sets the user visible name of this channel. You can rename this channel when the system locale changes by listening for the ACTION_LOCALE_CHANGED broadcast.
The recommended maximum length is 40 characters; the value may be truncated if it is too long.
setShowBadge
public @NonNull 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 createNotificationChannel.
| Parameters | |
|---|---|
boolean showBadge |
true if badges should be allowed to be shown. |
setSound
public @NonNull NotificationChannelCompat.Builder setSound(@Nullable Uri sound, @Nullable AudioAttributes audioAttributes)
Sets the sound that should be played for notifications posted to this channel and its audio attributes. Notification channels with an setImportance importance} of at least IMPORTANCE_DEFAULT should have a sound. Only modifiable before the channel is submitted to createNotificationChannel.
setVibrationEnabled
public @NonNull NotificationChannelCompat.Builder setVibrationEnabled(boolean vibration)
Sets whether notification posted to this channel should vibrate. The vibration pattern can be set with setVibrationPattern. Only modifiable before the channel is submitted to createNotificationChannel.
setVibrationPattern
public @NonNull NotificationChannelCompat.Builder setVibrationPattern(@Nullable long[] vibrationPattern)
Sets the vibration pattern for notifications posted to this channel. If the provided pattern is valid (non-null, non-empty), will setVibrationEnabled enable vibration} as well. Otherwise, vibration will be disabled. Only modifiable before the channel is submitted to createNotificationChannel.