# 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 />

```
class NotificationChannelCompat.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationChannelCompat.Builder#Builder(java.lang.String,int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, importance: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates a notification channel builder. |

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

```
Builder(id: String, importance: Int)
```

Creates a notification channel builder.

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The id of the channel. Must be unique per package. The value may be truncated if it is too long. |
| `importance: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The importance of the channel. This controls how interruptive notifications posted to this channel are. |

## Public functions

### build

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

```
fun build(): NotificationChannelCompat
```

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

### setConversationId

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

```
fun setConversationId(parentChannelId: String, conversationId: String): NotificationChannelCompat.Builder
```

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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The `https://developer.android.com/reference/kotlin/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.' |
| `conversationId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The `https://developer.android.com/reference/kotlin/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)

```
fun setDescription(description: String?): NotificationChannelCompat.Builder
```

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)

```
fun setGroup(groupId: String?): NotificationChannelCompat.Builder
```

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

| Parameters |
|---|---|
| `groupId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | the id of a group created by `https://developer.android.com/reference/kotlin/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)

```
fun setImportance(importance: Int): NotificationChannelCompat.Builder
```

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

| Parameters |
|---|---|
| `importance: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | 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)

```
fun setLightColor(argb: Int): NotificationChannelCompat.Builder
```

Sets the notification light color for notifications posted to this channel, if lights are `https://developer.android.com/reference/kotlin/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/kotlin/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)

```
fun setLightsEnabled(lights: Boolean): NotificationChannelCompat.Builder
```

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/kotlin/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)

```
fun setName(name: CharSequence?): NotificationChannelCompat.Builder
```

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)

```
fun setShowBadge(showBadge: Boolean): NotificationChannelCompat.Builder
```

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/kotlin/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.

| Parameters |
|---|---|
| `showBadge: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | 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)

```
fun setSound(sound: Uri?, audioAttributes: AudioAttributes?): NotificationChannelCompat.Builder
```

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

```
fun setVibrationEnabled(vibration: Boolean): NotificationChannelCompat.Builder
```

Sets whether notification posted to this channel should vibrate. The vibration pattern can be set with `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationChannelCompat.Builder#setVibrationPattern(long[])`. Only modifiable before the channel is submitted to `https://developer.android.com/reference/kotlin/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)

```
fun setVibrationPattern(vibrationPattern: LongArray<Long>?): NotificationChannelCompat.Builder
```

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/kotlin/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/kotlin/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat)`.