MediaStyleNotificationHelper.DecoratedMediaCustomViewStyle


public class MediaStyleNotificationHelper.DecoratedMediaCustomViewStyle extends MediaStyleNotificationHelper.MediaStyle


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.

Use #setCustomContentView(RemoteViews), #setCustomBigContentView(RemoteViews) and #setCustomHeadsUpContentView(RemoteViews) to set the corresponding custom views to display.

To use this style with your Notification, feed it to #setStyle(androidx.core.app.NotificationCompat.Style) like so:

Notification noti = new NotificationCompat.Builder()
    .setSmallIcon(androidx.media.R.drawable.ic_stat_player)
    .setLargeIcon(albumArtBitmap))
    .setCustomContentView(contentView)
    .setStyle(new NotificationCompat.DecoratedMediaCustomViewStyle()
         .setMediaSession(mySession))
    .build();

If you are using this style, consider using the corresponding styles like TextAppearance_Compat_Notification_Media or TextAppearance_Compat_Notification_Title_Media in your custom views in order to get the correct styling on each platform version.

Summary

Public constructors

Inherited methods

From androidx.media3.session.MediaStyleNotificationHelper.MediaStyle
static @Nullable SessionToken

Extracts a SessionToken from the extra values in the MediaStyle notification.

MediaStyleNotificationHelper.MediaStyle

Sets the pending intent to be sent when the cancel button is pressed.

MediaStyleNotificationHelper.MediaStyle
@CanIgnoreReturnValue
@RequiresPermission(value = "android.permission.MEDIA_CONTENT_CONTROL")
setRemotePlaybackInfo(
    CharSequence deviceName,
    @DrawableRes int iconResource,
    @Nullable 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.

MediaStyleNotificationHelper.MediaStyle

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

MediaStyleNotificationHelper.MediaStyle

Sets whether a cancel button at the top right should be shown in the notification on platforms before Lollipop.

From androidx.core.app.NotificationCompat.Style
@Nullable Notification

If this Style object has been set on a notification builder, this method will build that notification and return it.

void

Link this rich notification style with a notification builder.

Public constructors

DecoratedMediaCustomViewStyle

public DecoratedMediaCustomViewStyle(MediaSession session)

Public methods

apply

public void apply(NotificationBuilderWithBuilderAccessor builder)

Applies the compat style data to the framework Notification in a backwards compatible way. All other data should be stored within the Notification's extras.