# NotificationChannelCompat.Builder

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/app/NotificationChannelCompat.java+class:androidx.core.app.NotificationChannelCompat.Builder) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

*** ** * ** ***

<br />

```
public class NotificationChannelCompat.Builder
```

<br />

*** ** * ** ***

Builder class for `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat` objects.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#Builder(java.lang.String,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html id, int importance)` Creates a notification channel builder. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#build()()` Creates a `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat` instance. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setConversationId(java.lang.String,java.lang.String)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html parentChannelId, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html conversationId )` Sets this channel as being conversation-centric. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setDescription(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html description)` Sets the user visible description of this channel. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setGroup(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html groupId)` Sets what group this channel belongs to. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setImportance(int)(int importance)` Sets the level of interruption of this notification channel. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setLightColor(int)(int argb)` Sets the notification light color for notifications posted to this channel, if lights are `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setLightsEnabled(boolean)` on this channel and the device supports that feature. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setLightsEnabled(boolean)(boolean lights)` Sets whether notifications posted to this channel should display notification lights, on devices that support that feature. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setName(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html name)` Sets the user visible name of this channel. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setShowBadge(boolean)(boolean showBadge)` Sets whether notifications posted to this channel can appear as application icon badges in a Launcher. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setSound(android.net.Uri,android.media.AudioAttributes)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html sound, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/media/AudioAttributes.html audioAttributes)` Sets the sound that should be played for notifications posted to this channel and its audio attributes. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setVibrationEnabled(boolean)(boolean vibration)` Sets whether notification posted to this channel should vibrate. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setVibrationPattern(long[])(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html long[] vibrationPattern)` Sets the vibration pattern for notifications posted to this channel. |

## Public constructors

### Builder

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public Builder(@NonNull String id, int importance)
```

Creates a notification channel builder.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html id` | The id of the channel. Must be unique per package. The value may be truncated if it is too long. |
| `int importance` | The importance of the channel. This controls how interruptive notifications posted to this channel are. |

## Public methods

### build

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @NonNull NotificationChannelCompat build()
```

Creates a `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat` instance.

### setConversationId

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html parentChannelId` | The `https://developer.android.com/reference/androidx/core/app/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.' |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html conversationId` | The `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getId()` of the shortcut representing this channel's conversation. |

### setDescription

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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 `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`, unless the channel is not currently part of a group.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html groupId` | the id of a group created by `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannelGroup(android.app.NotificationChannelGroup)`. |

### setImportance

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @NonNull NotificationChannelCompat.Builder setImportance(int importance)
```

Sets the level of interruption of this notification channel. Only modifiable before the channel is submitted to `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.

| Parameters |
|---|---|
| `int importance` | the amount the user should be interrupted by notifications from this channel. |

### setLightColor

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @NonNull NotificationChannelCompat.Builder setLightColor(int argb)
```

Sets the notification light color for notifications posted to this channel, if lights are `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setLightsEnabled(boolean)` on this channel and the device supports that feature. Only modifiable before the channel is submitted to `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.

### setLightsEnabled

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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 `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.

### setName

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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 `https://developer.android.com/reference/android/content/Intent.html#ACTION_LOCALE_CHANGED` broadcast.

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

### setShowBadge

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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 `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.

| Parameters |
|---|---|
| `boolean showBadge` | true if badges should be allowed to be shown. |

### setSound

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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 `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setImportance(int)` importance} of at least `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#IMPORTANCE_DEFAULT()` should have a sound. Only modifiable before the channel is submitted to `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.

### setVibrationEnabled

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @NonNull NotificationChannelCompat.Builder setVibrationEnabled(boolean vibration)
```

Sets whether notification posted to this channel should vibrate. The vibration pattern can be set with `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setVibrationPattern(long[])`. Only modifiable before the channel is submitted to `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.

### setVibrationPattern

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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 `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#setVibrationEnabled(boolean)` enable vibration} as well. Otherwise, vibration will be disabled. Only modifiable before the channel is submitted to `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.