# Notification.MediaStyle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# MediaStyle

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/Notification.MediaStyle "View this page in Java")  

```
open class MediaStyle : Notification.Style
```

|---|---|----------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                |||
| ↳ | [android.app.Notification.Style](https://developer.android.com/reference/kotlin/android/app/Notification.Style)               ||
|   | ↳ | [android.app.Notification.MediaStyle](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#) |

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [Notification.DecoratedMediaCustomViewStyle](https://developer.android.com/reference/kotlin/android/app/Notification.DecoratedMediaCustomViewStyle) |-----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------| | [Notification.DecoratedMediaCustomViewStyle](https://developer.android.com/reference/kotlin/android/app/Notification.DecoratedMediaCustomViewStyle) | Notification style for media custom views that are decorated by the system | |

Notification style for media playback notifications.

In the expanded form,[Notification.bigContentView](https://developer.android.com/reference/kotlin/android/app/Notification#bigContentView:android.widget.RemoteViews), up to 5[Notification.Action](https://developer.android.com/reference/kotlin/android/app/Notification.Action)s specified with[addAction](https://developer.android.com/reference/kotlin/android/app/Notification.Builder#addAction(android.app.Notification.Action))will be shown as icon-only pushbuttons, suitable for transport controls. The Bitmap given to[setLargeIcon()](https://developer.android.com/reference/kotlin/android/app/Notification.Builder#setLargeIcon(android.graphics.Bitmap))will be treated as album artwork.

Unlike the other styles provided here, MediaStyle can also modify the standard-size[Notification.contentView](https://developer.android.com/reference/kotlin/android/app/Notification#contentView:android.widget.RemoteViews); by providing action indices to[setShowActionsInCompactView(int...)](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#setShowActionsInCompactView(kotlin.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[CATEGORY_TRANSPORT](https://developer.android.com/reference/kotlin/android/app/Notification#CATEGORY_TRANSPORT:kotlin.String)unless you set a different category using[setCategory()](https://developer.android.com/reference/kotlin/android/app/Notification.Builder#setCategory(kotlin.String)).

Finally, if you attach a[android.media.session.MediaSession.Token](https://developer.android.com/reference/kotlin/android/media/session/MediaSession.Token.html#)using[android.app.Notification.MediaStyle#setMediaSession(MediaSession.Token)](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#setMediaSession(android.media.session.MediaSession.Token)), 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).

Starting at[Android O](https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#O:kotlin.Int)any notification that has a media session attached with[setMediaSession(android.media.session.MediaSession.Token)](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#setMediaSession(android.media.session.MediaSession.Token))will be colorized. You can opt-out of this behavior by using[Notification.Builder.setColorized(boolean)](https://developer.android.com/reference/kotlin/android/app/Notification.Builder#setColorized(kotlin.Boolean)).

<br />

Starting at[Android V](https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#VANILLA_ICE_CREAM:kotlin.Int)the[NO_CLEAR flag](https://developer.android.com/reference/kotlin/android/app/Notification#FLAG_NO_CLEAR:kotlin.Int)will be set for valid MediaStyle notifications.

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

```kotlin
Notification noti = new Notification.Builder()
      .setSmallIcon(R.drawable.ic_stat_player)
      .setContentTitle("Track title")
      .setContentText("Artist - Album")
      .setLargeIcon(albumArtBitmap))
      .setStyle(<b>new Notification.MediaStyle()</b>.setMediaSession(mySession))
      .build();
  
```

## Summary

|                                                                                                                               Public constructors                                                                                                                                ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [MediaStyle](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#MediaStyle())`()` <br />                                                                                                                                                      |
| [MediaStyle](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#MediaStyle(android.app.Notification.Builder))`(`builder:` `[Notification.Builder](https://developer.android.com/reference/kotlin/android/app/Notification.Builder)!`)` <br /> |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ||
|---------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Notification.MediaStyle](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#)! | [setMediaSession](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#setMediaSession(android.media.session.MediaSession.Token))`(`token:` `[MediaSession.Token](https://developer.android.com/reference/kotlin/android/media/session/MediaSession.Token.html#)!`)` Attach a[android.media.session.MediaSession.Token](https://developer.android.com/reference/kotlin/android/media/session/MediaSession.Token.html#)to this Notification to provide additional playback information and control to the SystemUI.                                                                                                                                                                                                                                                                              |
| open[Notification.MediaStyle](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#)  | [setRemotePlaybackInfo](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#setRemotePlaybackInfo(kotlin.CharSequence,%20kotlin.Int,%20android.app.PendingIntent))`(`deviceName:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`, `iconResource:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `chipIntent:` `[PendingIntent](https://developer.android.com/reference/kotlin/android/app/PendingIntent)?`)` 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. |
| open[Notification.MediaStyle](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#)! | [setShowActionsInCompactView](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#setShowActionsInCompactView(kotlin.Int))`(`vararg` `actions:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Request up to 3 actions (by index in the order of addition) to be shown in the compact notification view.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

| Inherited functions ||
|---|---|
| From class[Style](https://developer.android.com/reference/kotlin/android/app/Notification.Style) |-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Notification](https://developer.android.com/reference/kotlin/android/app/Notification)!        | [build](https://developer.android.com/reference/kotlin/android/app/Notification.Style#build())`()` <br /> Calls[android.app.Notification.Builder#build()](https://developer.android.com/reference/kotlin/android/app/Notification.Builder#build())on the Builder this Style is attached to. Note: Calling build() multiple times returns the same Notification instance, so reusing a builder to create multiple Notifications is discouraged. <br /> | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                    | [checkBuilder](https://developer.android.com/reference/kotlin/android/app/Notification.Style#checkBuilder())`()` <br />                                                                                                                                                                                                                                                                                                                               | | [RemoteViews](https://developer.android.com/reference/kotlin/android/widget/RemoteViews.html#)! | [getStandardView](https://developer.android.com/reference/kotlin/android/app/Notification.Style#getStandardView(kotlin.Int))`(`layoutId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br />                                                                                                                                                                                                                       | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                    | [internalSetBigContentTitle](https://developer.android.com/reference/kotlin/android/app/Notification.Style#internalSetBigContentTitle(kotlin.CharSequence))`(`title:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` <br /> Overrides ContentTitle in the expanded form of the template. This defaults to the value passed to setContentTitle(). <br />                                           | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                    | [internalSetSummaryText](https://developer.android.com/reference/kotlin/android/app/Notification.Style#internalSetSummaryText(kotlin.CharSequence))`(`cs:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` <br /> Set the first line of text after the detail section in the expanded form of the template. <br />                                                                                 | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                    | [setBuilder](https://developer.android.com/reference/kotlin/android/app/Notification.Style#setBuilder(android.app.Notification.Builder))`(`builder:` `[Notification.Builder](https://developer.android.com/reference/kotlin/android/app/Notification.Builder)!`)` <br />                                                                                                                                                                              | ||

| Inherited properties ||
|---|---|
| From class[Style](https://developer.android.com/reference/kotlin/android/app/Notification.Style) |----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------| | [Notification.Builder](https://developer.android.com/reference/kotlin/android/app/Notification.Builder)! | [mBuilder](https://developer.android.com/reference/kotlin/android/app/Notification.Style#mBuilder:android.app.Notification.Builder) <br /> | ||

## Public constructors

### MediaStyle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
MediaStyle()
```  

### MediaStyle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
MediaStyle(builder: Notification.Builder!)
```

**Deprecated:** *use`MediaStyle()`.*

## Public methods

### setMediaSession

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setMediaSession(token: MediaSession.Token!): Notification.MediaStyle!
```

Attach a[android.media.session.MediaSession.Token](https://developer.android.com/reference/kotlin/android/media/session/MediaSession.Token.html#)to this Notification to provide additional playback information and control to the SystemUI.  

### setRemotePlaybackInfo

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setRemotePlaybackInfo(
    deviceName: CharSequence, 
    iconResource: Int, 
    chipIntent: PendingIntent?
): Notification.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.

This method is 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.  
Requires[android.Manifest.permission#MEDIA_CONTENT_CONTROL](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#MEDIA_CONTENT_CONTROL:kotlin.String)

|                                                                                                                                            Parameters                                                                                                                                             ||
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `deviceName`   | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html):the name of the remote device to display This value cannot be`null`.                                                                                                                |
| `iconResource` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):icon resource representing the device                                                                                                                                                                  |
| `chipIntent`   | [PendingIntent](https://developer.android.com/reference/kotlin/android/app/PendingIntent)?: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 Activity or it will be ignored. |

|                                                                         Return                                                                         ||
|----------------------------------------------------------------------------------------------------------------|----------------------------------------|
| [Notification.MediaStyle](https://developer.android.com/reference/kotlin/android/app/Notification.MediaStyle#) | MediaStyle This value cannot be`null`. |

### setShowActionsInCompactView

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setShowActionsInCompactView(vararg actions: Int): Notification.MediaStyle!
```

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

|                                                                        Parameters                                                                         ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `actions` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the indices of the actions to show in the compact notification view |