# MediaStyleNotificationHelper.MediaStyle

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

*** ** * ** ***


```
class MediaStyleNotificationHelper.MediaStyle : NotificationCompat.Style
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.core.app.NotificationCompat.Style](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Style) ||
|   | ↳ | [androidx.media3.session.MediaStyleNotificationHelper.MediaStyle](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle) |

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

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.DecoratedMediaCustomViewStyle` | Notification style for media custom views that are decorated by the system. |

*** ** * ** ***

Notification style for media playback notifications.

In the expanded form, up to 5 `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` specified with `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder` will be shown as icon-only push buttons, suitable for transport controls. The Bitmap given to `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder` will be treated as album artwork.

Unlike the other styles provided here, MediaStyle can also modify the standard-size content view; by providing action indices to `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#setShowActionsInCompactView(int...)` you can promote up to 3 actions to be displayed in the standard view alongside the usual content.

Notifications created with MediaStyle will have their category set to `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat#CATEGORY_TRANSPORT()` unless you set a different category using `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#setCategory(java.lang.String)`.

Finally, the System UI can identify this as a notification representing an active media session and respond accordingly (by showing album artwork in the lockscreen, for example).

To use this style with your Notification, feed it to `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#setStyle(androidx.core.app.NotificationCompat.Style)` like so:

```kotlin
Notification noti = new NotificationCompat.Builder()
    .setSmallIcon(androidx.media3.R.drawable.media3_notification_small_icon)
    .setContentTitle("Track title")
    .setContentText("Artist - Album")
    .setLargeIcon(albumArtBitmap)
    .setStyle(new MediaStyleNotificationHelper.MediaStyle(mySession))
    .build();
```

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/Notification.html#bigContentView` |   |

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#MediaStyle(androidx.media3.session.MediaSession)(session: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!)` Creates a new instance with a `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession` to this Notification to provide additional playback information and control to the SystemUI. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#apply(androidx.core.app.NotificationBuilderWithBuilderAccessor)(builder: https://developer.android.com/reference/kotlin/androidx/core/app/NotificationBuilderWithBuilderAccessor!)` Applies the compat style data to the framework `https://developer.android.com/reference/android/app/Notification.html` in a backwards compatible way. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/session/SessionToken?` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#getSessionToken(android.app.Notification)(notification: https://developer.android.com/reference/android/app/Notification.html!)` Extracts a `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionToken` from the extra values in the `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle``https://developer.android.com/reference/android/app/Notification.html`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html [setCancelButtonIntent](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#setCancelButtonIntent(android.app.PendingIntent))(pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html!)` **This function is deprecated.** This method is a no-op and usages can be safely removed. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresPermission(value = "android.permission.MEDIA_CONTENT_CONTROL") https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#setRemotePlaybackInfo(java.lang.CharSequence,int,android.app.PendingIntent)( deviceName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, iconResource: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, chipIntent: https://developer.android.com/reference/android/app/PendingIntent.html? )` For media notifications associated with playback on a remote device, provide device information that will replace the default values for the output switcher chip on the media control, as well as an intent to use when the output switcher chip is tapped, on devices where this is supported. |
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#setShowActionsInCompactView(int...)(actions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)` Requests up to 3 actions (by index in the order of addition) to be shown in the compact notification view. |
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html [setShowCancelButton](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#setShowCancelButton(boolean))(show: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` **This function is deprecated.** This method is a no-op and usages can be safely removed. <br /> |

### Inherited functions

From [androidx.core.app.NotificationCompat.Style](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Style) `https://developer.android.com/reference/android/app/Notification.html?` `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Style#build()()`

If this Style object has been set on a notification builder, this method will build that notification and return it.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Style#setBuilder(androidx.core.app.NotificationCompat.Builder)(builder: https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder?)`

Link this rich notification style with a notification builder.

## Public constructors

### MediaStyle

```
MediaStyle(session: MediaSession!)
```

Creates a new instance with a `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession` to this Notification to provide additional playback information and control to the SystemUI.

## Public functions

### apply

```
fun apply(builder: NotificationBuilderWithBuilderAccessor!): Unit
```

Applies the compat style data to the framework `https://developer.android.com/reference/android/app/Notification.html` in a backwards compatible way. All other data should be stored within the Notification's extras.

### getSessionToken

```
java-static fun getSessionToken(notification: Notification!): SessionToken?
```

Extracts a `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionToken` from the extra values in the `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle``https://developer.android.com/reference/android/app/Notification.html`.

| Parameters |
|---|---|
| `notification: https://developer.android.com/reference/android/app/Notification.html!` | The notification to extract a `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession` from. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionToken?` | The `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionToken` in the `notification` if it contains, null otherwise. |

### setCancelButtonIntent

```
@CanIgnoreReturnValue
fun [setCancelButtonIntent](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#setCancelButtonIntent(android.app.PendingIntent))(pendingIntent: PendingIntent!): MediaStyleNotificationHelper.MediaStyle!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> This method is a no-op and usages can be safely removed. There is no recommended alternative (it was previously only operational on API \<21).

### setRemotePlaybackInfo

```
@CanIgnoreReturnValue
@RequiresPermission(value = "android.permission.MEDIA_CONTENT_CONTROL")
fun setRemotePlaybackInfo(
    deviceName: CharSequence!,
    iconResource: @DrawableRes Int,
    chipIntent: PendingIntent?
): MediaStyleNotificationHelper.MediaStyle!
```

For media notifications associated with playback on a remote device, provide device information that will replace the default values for the output switcher chip on the media control, as well as an intent to use when the output switcher chip is tapped, on devices where this is supported.

Most apps should integrate with `https://developer.android.com/reference/android/media/MediaRouter2.html` instead. This method is only intended for system applications to provide information and/or functionality that would otherwise be unavailable to the default output switcher because the media originated on a remote device.

Also note that this method is a no-op when running on API 33 or lower.

| Parameters |
|---|---|
| `deviceName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The name of the remote device to display. |
| `iconResource: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Icon resource, of size 12, representing the device. |
| `chipIntent: https://developer.android.com/reference/android/app/PendingIntent.html?` | PendingIntent to send when the output switcher is tapped. May be ` null`, in which case the output switcher will be disabled. This intent should open an `https://developer.android.com/reference/android/app/Activity.html` or it will be ignored. |

### setShowActionsInCompactView

```
@CanIgnoreReturnValue
fun setShowActionsInCompactView(actions: IntArray<Int>!): MediaStyleNotificationHelper.MediaStyle!
```

Requests up to 3 actions (by index in the order of addition) to be shown in the compact notification view.

| Parameters |
|---|---|
| `actions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | the indices of the actions to show in the compact notification view |

### setShowCancelButton

```
@CanIgnoreReturnValue
fun [setShowCancelButton](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaStyleNotificationHelper.MediaStyle#setShowCancelButton(boolean))(show: Boolean): MediaStyleNotificationHelper.MediaStyle!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> This method is a no-op and usages can be safely removed. There is no recommended alternative (it was previously only operational on API \<21).