Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited Fields](https://developer.android.com/reference/android/app/Notification.MediaStyle#inhfields) \| [Ctors](https://developer.android.com/reference/android/app/Notification.MediaStyle#pubctors) \| [Methods](https://developer.android.com/reference/android/app/Notification.MediaStyle#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/Notification.MediaStyle#inhmethods)

# Notification.MediaStyle

*** ** * ** ***


`
public
static


class
Notification.MediaStyle
`


`


`

`

extends https://developer.android.com/reference/android/app/Notification.Style


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.app.Notification.Style](https://developer.android.com/reference/android/app/Notification.Style) ||
|   | ↳ | android.app.Notification.MediaStyle |

|---|
| Known direct subclasses [Notification.DecoratedMediaCustomViewStyle](https://developer.android.com/reference/android/app/Notification.DecoratedMediaCustomViewStyle) |---|---| | [Notification.DecoratedMediaCustomViewStyle](https://developer.android.com/reference/android/app/Notification.DecoratedMediaCustomViewStyle) | Notification style for media custom views that are decorated by the system Instead of providing a media notification that is completely custom, a developer can set this style and still obtain system decorations like the notification header with the expand affordance and actions. | |

<br />

*** ** * ** ***

Notification style for media playback notifications.

In the expanded form, `https://developer.android.com/reference/android/app/Notification#bigContentView`, up to 5
`https://developer.android.com/reference/android/app/Notification.Action`s specified with
`https://developer.android.com/reference/android/app/Notification.Builder#addAction(android.app.Notification.Action)` will be
shown as icon-only pushbuttons, suitable for transport controls. The Bitmap given to
`https://developer.android.com/reference/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
`https://developer.android.com/reference/android/app/Notification#contentView`; by providing action indices to
`https://developer.android.com/reference/android/app/Notification.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/android/app/Notification#CATEGORY_TRANSPORT` unless you set a different
category using `https://developer.android.com/reference/android/app/Notification.Builder#setCategory(java.lang.String)`.


Finally, if you attach a `https://developer.android.com/reference/android/media/session/MediaSession.Token` using
`https://developer.android.com/reference/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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O` any notification that has a
media session attached with `https://developer.android.com/reference/android/app/Notification.MediaStyle#setMediaSession(android.media.session.MediaSession.Token)` will be colorized.
You can opt-out of this behavior by using `https://developer.android.com/reference/android/app/Notification.Builder#setColorized(boolean)`.


Starting at `https://developer.android.com/reference/android/os/Build.VERSION_CODES#VANILLA_ICE_CREAM` the
`https://developer.android.com/reference/android/app/Notification#FLAG_NO_CLEAR` will be set for valid MediaStyle
notifications.


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

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

<br />

**See also:**

- `https://developer.android.com/reference/android/app/Notification#bigContentView`
- `https://developer.android.com/reference/android/app/Notification.Builder#setColorized(boolean)`

## Summary

| ### Inherited fields |
|---|
| From class `https://developer.android.com/reference/android/app/Notification.Style` |---|---| | ` protected https://developer.android.com/reference/android/app/Notification.Builder` | `https://developer.android.com/reference/android/app/Notification.Style#mBuilder` | |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/Notification.MediaStyle#MediaStyle()() ` |
| ` https://developer.android.com/reference/android/app/Notification.MediaStyle#MediaStyle(android.app.Notification.Builder)(https://developer.android.com/reference/android/app/Notification.Builder builder) ` *This constructor is deprecated. use `MediaStyle()`.* |

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

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/android/app/Notification.Style ` |---|---| | ` https://developer.android.com/reference/android/app/Notification` | ` https://developer.android.com/reference/android/app/Notification.Style#build()() ` Calls `https://developer.android.com/reference/android/app/Notification.Builder#build()` on the Builder this Style is attached to. | | ` void` | ` https://developer.android.com/reference/android/app/Notification.Style#checkBuilder()() ` | | ` https://developer.android.com/reference/android/widget/RemoteViews` | ` https://developer.android.com/reference/android/app/Notification.Style#getStandardView(int)(int layoutId) ` | | ` void` | ` https://developer.android.com/reference/android/app/Notification.Style#internalSetBigContentTitle(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence title) ` Overrides ContentTitle in the expanded form of the template. | | ` void` | ` https://developer.android.com/reference/android/app/Notification.Style#internalSetSummaryText(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence cs) ` Set the first line of text after the detail section in the expanded form of the template. | | ` void` | ` https://developer.android.com/reference/android/app/Notification.Style#setBuilder(android.app.Notification.Builder)(https://developer.android.com/reference/android/app/Notification.Builder builder) ` | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### MediaStyle

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

```
public MediaStyle ()
```

<br />

<br />

### MediaStyle

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

```
public MediaStyle (Notification.Builder builder)
```


**This constructor is deprecated.**   

use `MediaStyle()`.

<br />

<br />

| Parameters ||
|---|---|
| `builder` | `Notification.Builder` <br /> |

## Public methods

### setMediaSession

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

```
public Notification.MediaStyle setMediaSession (MediaSession.Token token)
```

Attach a `https://developer.android.com/reference/android/media/session/MediaSession.Token` to this Notification
to provide additional playback information and control to the SystemUI.

<br />

| Parameters ||
|---|---|
| `token` | `MediaSession.Token` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.MediaStyle` | <br /> |

### setRemotePlaybackInfo

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

```
public Notification.MediaStyle setRemotePlaybackInfo (CharSequence deviceName, 
                int iconResource, 
                PendingIntent chipIntent)
```

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 `https://developer.android.com/reference/android/Manifest.permission#MEDIA_CONTENT_CONTROL`

<br />

| Parameters ||
|---|---|
| `deviceName` | `CharSequence`: the name of the remote device to display. This value cannot be `null`. <br /> |
| `iconResource` | `int`: icon resource representing the device <br /> |
| `chipIntent` | `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. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.MediaStyle` | MediaStyle. This value cannot be `null`. <br /> |

### setShowActionsInCompactView

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

```
public Notification.MediaStyle setShowActionsInCompactView (int... actions)
```

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

<br />

| Parameters ||
|---|---|
| `actions` | `int`: the indices of the actions to show in the compact notification view <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.MediaStyle` | <br /> |