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

*** ** * ** ***


```
class MediaNotification
```

<br />

*** ** * ** ***

A notification for media playbacks.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi interface https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.ActionFactory` Creates `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` and `https://developer.android.com/reference/android/app/PendingIntent.html` for notifications. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi interface https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.Provider` Provides `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification` to be posted as notifications that reflect the state of a `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaController` and to send media commands to a `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession`. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.Provider.Callback` Receives updates for a notification. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.Provider.NotificationChannelInfo` Properties of the notification channel used for the notification. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/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 constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification#MediaNotification(int,android.app.Notification)( notificationId: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, notification: https://developer.android.com/reference/android/app/Notification.html! )` Creates an instance. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/android/app/Notification.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification#notification()` The `https://developer.android.com/reference/android/app/Notification.html`. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification#notificationId()` The notification id. |

## Constants

### NOTIFICATION_DISMISSED_EVENT_KEY

```
@UnstableApi
const val NOTIFICATION_DISMISSED_EVENT_KEY = "androidx.media3.session.NOTIFICATION_DISMISSED_EVENT_KEY": String!
```

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 constructors

### MediaNotification

```
MediaNotification(
    notificationId: @IntRange(from = 1) Int,
    notification: Notification!
)
```

Creates an instance.

| Parameters |
|---|---|
| `notificationId: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The notification id to be used for `https://developer.android.com/reference/android/app/NotificationManager.html#notify(int, android.app.Notification)`. |
| `notification: https://developer.android.com/reference/android/app/Notification.html!` | A `https://developer.android.com/reference/android/app/Notification.html` that reflects the state of a `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaController` and to send media commands to a `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle``https://developer.android.com/reference/android/app/Notification.html`. |

## Public properties

### notification

```
val notification: Notification!
```

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

### notificationId

```
val notificationId: @IntRange(from = 1) Int
```

The notification id.