# MediaNotification

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)

*** ** * ** ***


```
public final class MediaNotification
```

<br />

*** ** * ** ***

A notification for media playbacks.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi public interface https://developer.android.com/reference/androidx/media3/session/MediaNotification.ActionFactory` Creates `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action` and `https://developer.android.com/reference/android/app/PendingIntent.html` for notifications. |
| `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi public interface 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`. |
| `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. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaNotification#NOTIFICATION_DISMISSED_EVENT_KEY() = "androidx.media3.session.NOTIFICATION_DISMISSED_EVENT_KEY"` Event key to indicate a media notification was dismissed. |

| ### Public fields |
|---|---|
| `final https://developer.android.com/reference/android/app/Notification.html` | `https://developer.android.com/reference/androidx/media3/session/MediaNotification#notification()` The `https://developer.android.com/reference/android/app/Notification.html`. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int` | `https://developer.android.com/reference/androidx/media3/session/MediaNotification#notificationId()` The notification id. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaNotification#MediaNotification(int,android.app.Notification)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int notificationId, https://developer.android.com/reference/android/app/Notification.html notification )` Creates an instance. |

## Constants

### NOTIFICATION_DISMISSED_EVENT_KEY

```
@UnstableApi
public static final String NOTIFICATION_DISMISSED_EVENT_KEY = "androidx.media3.session.NOTIFICATION_DISMISSED_EVENT_KEY"
```

Event key to indicate a media notification was dismissed.

This event key can be used as an extras key for a boolean extra on a media button pending intent, and as custom session command action to inform the media notification controller that a notification was dismissed.

## Public fields

### notification

```
public final Notification notification
```

The `https://developer.android.com/reference/android/app/Notification.html`.

### notificationId

```
public final @IntRange(from = 1) int notificationId
```

The notification id.

## Public constructors

### MediaNotification

```
public MediaNotification(
    @IntRange(from = 1) int notificationId,
    Notification notification
)
```

Creates an instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int notificationId` | The notification id to be used for `https://developer.android.com/reference/android/app/NotificationManager.html#notify(int, android.app.Notification)`. |
| `https://developer.android.com/reference/android/app/Notification.html notification` | A `https://developer.android.com/reference/android/app/Notification.html` that reflects 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 notification may be used to start a service in the [foreground](https://developer.android.com/guide/components/foreground-services). It's highly recommended to use a `https://developer.android.com/reference/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle``https://developer.android.com/reference/android/app/Notification.html`. |