public static class Notification.MediaStyle extends Notification.Style
Notification.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
Notification.contentView
; by providing action indices to
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
CATEGORY_TRANSPORT
unless you set a different
category using setCategory()
.
Finally, if you attach a MediaSession.Token
using
setMediaSession(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).
To use this style with your Notification, feed it to
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();
Notification.bigContentView
mBuilder, mSummaryText, mSummaryTextSet
Constructor and Description |
---|
MediaStyle() |
MediaStyle(Notification.Builder builder)
Deprecated.
use
MediaStyle() . |
Modifier and Type | Method and Description |
---|---|
void |
addExtras(Bundle extras)
Apply any style-specific extras to this notification before shipping it out.
|
Notification |
buildStyled(Notification wip) |
protected boolean |
hasProgress() |
RemoteViews |
makeBigContentView()
Construct a Style-specific RemoteViews for the final big notification layout.
|
RemoteViews |
makeContentView()
Construct a Style-specific RemoteViews for the final 1U notification layout.
|
RemoteViews |
makeHeadsUpContentView()
Construct a Style-specific RemoteViews for the final HUN layout.
|
protected void |
restoreFromExtras(Bundle extras)
Reconstruct the internal state of this Style object from extras.
|
Notification.MediaStyle |
setMediaSession(MediaSession.Token token)
Attach a
MediaSession.Token to this Notification
to provide additional playback information and control to the SystemUI. |
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.
|
build, checkBuilder, displayCustomViewInline, getStandardView, hasSummaryInHeader, internalSetBigContentTitle, internalSetSummaryText, purgeResources, setBuilder
public MediaStyle()
@Deprecated public MediaStyle(Notification.Builder builder)
MediaStyle()
.public Notification.MediaStyle setShowActionsInCompactView(int... actions)
actions
- the indices of the actions to show in the compact notification viewpublic Notification.MediaStyle setMediaSession(MediaSession.Token token)
MediaSession.Token
to this Notification
to provide additional playback information and control to the SystemUI.public Notification buildStyled(Notification wip)
buildStyled
in class Notification.Style
public RemoteViews makeContentView()
Notification.Style
makeContentView
in class Notification.Style
public RemoteViews makeBigContentView()
Notification.Style
makeBigContentView
in class Notification.Style
public RemoteViews makeHeadsUpContentView()
Notification.Style
makeHeadsUpContentView
in class Notification.Style
public void addExtras(Bundle extras)
Notification.Style
addExtras
in class Notification.Style
protected void restoreFromExtras(Bundle extras)
Notification.Style
restoreFromExtras
in class Notification.Style
protected boolean hasProgress()
hasProgress
in class Notification.Style