java.lang.Object | ||
↳ | android.app.Notification.Style | |
↳ | android.app.Notification.MediaStyle |
Notification style for media playback notifications.
In the expanded form, bigContentView
, up to 5
Notification.Action
s specified with
addAction
will be
shown as icon-only pushbuttons, suitable for transport controls. The Bitmap given to
setLargeIcon()
will be
treated as album artwork.
Unlike the other styles provided here, MediaStyle can also modify the standard-size
contentView
; by providing action indices to
setShowActionsInCompactView(int)
you can promote up to 2 actions to be displayed
in the standard view alongside the usual content.
Finally, if you attach a MediaSessionToken
using
setMediaSession(MediaSessionToken)
,
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
setStyle(android.app.Notification.Style)
like so:
Notification noti = new Notification.Builder() .setSmallIcon(R.drawable.ic_stat_player) .setContentTitle("Track title") // these three lines are optional .setContentText("Artist - Album") // if you use .setLargeIcon(albumArtBitmap)) // setMediaSession(token, true) .setMediaSession(mySession, true) .setStyle(new Notification.MediaStyle()) .build();
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Notification.Style
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Attach a
MediaSessionToken to this Notification to provide
additional playback information and control to the SystemUI. | |||||||||||
Request up to 2 actions (by index in the order of addition) to be shown in the compact
notification view.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Notification.Style
| |||||||||||
From class
java.lang.Object
|
Attach a MediaSessionToken
to this Notification to provide
additional playback information and control to the SystemUI.
Request up to 2 actions (by index in the order of addition) to be shown in the compact notification view.