# MediaNotification.Provider

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/MediaNotification.java+class:androidx.media3.session.MediaNotification.Provider)

*** ** * ** ***

<br />

```
@UnstableApi
public interface MediaNotification.Provider
```

<br />

Known direct subclasses [DefaultMediaNotificationProvider](https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider)

|---|---|
| `https://developer.android.com/reference/androidx/media3/session/DefaultMediaNotificationProvider` | The default `https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider`. |

*** ** * ** ***

Provides `https://developer.android.com/reference/androidx/media3/session/MediaNotification` to be posted as notifications that reflect the state of a `https://developer.android.com/reference/androidx/media3/session/MediaController` and to send media commands to a `https://developer.android.com/reference/androidx/media3/session/MediaSession`.

The provider is required to create a `https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat`, which is required to show notification for `SDK_INT >= 26`.

All methods will be called on the `https://developer.android.com/reference/androidx/media3/common/Player#getApplicationLooper()` of the `https://developer.android.com/reference/androidx/media3/common/Player` associated with the `https://developer.android.com/reference/androidx/media3/session/MediaSession` the notification is provided for.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider.Callback` Receives updates for a notification. |
| `public class https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider.NotificationChannelInfo` Properties of the notification channel used for the notification. |

| ### Public methods |
|---|---|
| `abstract https://developer.android.com/reference/androidx/media3/session/MediaNotification` | `https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider#createNotification(androidx.media3.session.MediaSession,com.google.common.collect.ImmutableList<androidx.media3.session.CommandButton>,androidx.media3.session.MediaNotification.ActionFactory,androidx.media3.session.MediaNotification.Provider.Callback)( https://developer.android.com/reference/androidx/media3/session/MediaSession mediaSession, https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/session/CommandButton> mediaButtonPreferences, https://developer.android.com/reference/androidx/media3/session/MediaNotification.ActionFactory actionFactory, https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider.Callback onNotificationChangedCallback )` Creates a new `https://developer.android.com/reference/androidx/media3/session/MediaNotification`. |
| `abstract https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider.NotificationChannelInfo` | `https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider#getNotificationChannelInfo()()` Returns the info of the notification channel used when creating a notification. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider#handleCustomCommand(androidx.media3.session.MediaSession,java.lang.String,android.os.Bundle)(https://developer.android.com/reference/androidx/media3/session/MediaSession session, https://developer.android.com/reference/java/lang/String.html action, https://developer.android.com/reference/android/os/Bundle.html extras)` Handles a notification's custom command. |

## Public methods

### createNotification

```
abstract MediaNotification createNotification(
    MediaSession mediaSession,
    ImmutableList<CommandButton> mediaButtonPreferences,
    MediaNotification.ActionFactory actionFactory,
    MediaNotification.Provider.Callback onNotificationChangedCallback
)
```

Creates a new `https://developer.android.com/reference/androidx/media3/session/MediaNotification`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaSession mediaSession` | The media session. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/session/CommandButton> mediaButtonPreferences` | The media button preferences `https://developer.android.com/reference/androidx/media3/session/MediaSession#setMediaButtonPreferences(androidx.media3.session.MediaSession.ControllerInfo,java.util.List<androidx.media3.session.CommandButton>)`. |
| `https://developer.android.com/reference/androidx/media3/session/MediaNotification.ActionFactory actionFactory` | The `https://developer.android.com/reference/androidx/media3/session/MediaNotification.ActionFactory` for creating notification `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action`. |
| `https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider.Callback onNotificationChangedCallback` | A callback that the provider needs to notify when the notification has changed and needs to be posted again, for example after a bitmap has been loaded asynchronously. |

### getNotificationChannelInfo

```
abstract MediaNotification.Provider.NotificationChannelInfo getNotificationChannelInfo()
```

Returns the info of the notification channel used when creating a notification.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider.NotificationChannelInfo` | The `https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider.NotificationChannelInfo`. |

### handleCustomCommand

```
abstract boolean handleCustomCommand(MediaSession session, String action, Bundle extras)
```

Handles a notification's custom command.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaSession session` | The media session. |
| `https://developer.android.com/reference/java/lang/String.html action` | The custom command action. |
| `https://developer.android.com/reference/android/os/Bundle.html extras` | A bundle `https://developer.android.com/reference/androidx/media3/session/SessionCommand#customExtras()`, otherwise `https://developer.android.com/reference/android/os/Bundle.html#EMPTY`. |

| Returns |
|---|---|
| `boolean` | `false` if the action should be delivered to the session as a custom command or `true` if the action has been handled completely by the provider. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaNotification.ActionFactory#createCustomAction(androidx.media3.session.MediaSession,androidx.core.graphics.drawable.IconCompat,java.lang.CharSequence,java.lang.String,android.os.Bundle)` |   |