# DefaultMediaNotificationProvider.Builder

Artifact: [androidx.media3:media3-session](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/session/DefaultMediaNotificationProvider.java+class:androidx.media3.session.DefaultMediaNotificationProvider.Builder)

*** ** * ** ***


```
public final class DefaultMediaNotificationProvider.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder#Builder(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Creates a builder. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider` | `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder#build()()` Builds the `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider`. |
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder#setChannelId(java.lang.String)(https://developer.android.com/reference/java/lang/String.html channelId)` Sets the ID of the `https://developer.android.com/reference/android/app/NotificationChannel.html` on which created notifications are posted on. |
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder#setChannelName(int)(@https://developer.android.com/reference/androidx/annotation/StringRes int channelNameResourceId)` Sets the name of the `https://developer.android.com/reference/android/app/NotificationChannel.html` on which created notifications are posted on. |
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder#setNotificationId(int)(int notificationId)` Sets the `https://developer.android.com/reference/androidx/media3/session/MediaNotification#notificationId()` used for the created notifications. |
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder#setNotificationIdProvider(androidx.media3.session.DefaultMediaNotificationProvider.NotificationIdProvider)( https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.NotificationIdProvider notificationIdProvider )` Sets the provider for the `https://developer.android.com/reference/androidx/media3/session/MediaNotification#notificationId()` used for the created notifications. |

## Public constructors

### Builder

```
public Builder(Context context)
```

Creates a builder.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | Any `https://developer.android.com/reference/android/content/Context.html`. |

## Public methods

### build

```
public DefaultMediaNotificationProvider build()
```

Builds the `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider`. The method can be called at most once.

### setChannelId

```
@CanIgnoreReturnValue
public DefaultMediaNotificationProvider.Builder setChannelId(String channelId)
```

Sets the ID of the `https://developer.android.com/reference/android/app/NotificationChannel.html` on which created notifications are posted on. By default, this is set to `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider#DEFAULT_CHANNEL_ID()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html channelId` | The channel ID. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder` | This builder. |

### setChannelName

```
@CanIgnoreReturnValue
public DefaultMediaNotificationProvider.Builder setChannelName(@StringRes int channelNameResourceId)
```

Sets the name of the `https://developer.android.com/reference/android/app/NotificationChannel.html` on which created notifications are posted on. By default, this is set to `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider#DEFAULT_CHANNEL_NAME_RESOURCE_ID()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/StringRes int channelNameResourceId` | The string resource ID with the channel name. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder` | This builder. |

### setNotificationId

```
@CanIgnoreReturnValue
public DefaultMediaNotificationProvider.Builder setNotificationId(int notificationId)
```

Sets the `https://developer.android.com/reference/androidx/media3/session/MediaNotification#notificationId()` used for the created notifications. By default, this is set to `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider#DEFAULT_NOTIFICATION_ID()`.

Overwrites anything set in `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder#setNotificationIdProvider(androidx.media3.session.DefaultMediaNotificationProvider.NotificationIdProvider)`.

| Parameters |
|---|---|
| `int notificationId` | The notification ID. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder` | This builder. |

### setNotificationIdProvider

```
@CanIgnoreReturnValue
public DefaultMediaNotificationProvider.Builder setNotificationIdProvider(
    DefaultMediaNotificationProvider.NotificationIdProvider notificationIdProvider
)
```

Sets the provider for the `https://developer.android.com/reference/androidx/media3/session/MediaNotification#notificationId()` used for the created notifications. By default, this is set to a provider that always returns `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider#DEFAULT_NOTIFICATION_ID()`.

Overwrites anything set in `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder#setNotificationId(int)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.NotificationIdProvider notificationIdProvider` | The notification ID provider. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider.Builder` | This builder. |