public interface

MediaNotification.ActionFactory

 androidx.media3.session.MediaNotification.ActionFactory

Overview

Creates and pending intents for notifications.

All methods will be called on the application thread of the Player associated with the MediaSession the notification is provided for.

Summary

Methods
public NotificationCompat.ActioncreateCustomAction(MediaSession mediaSession, IconCompat icon, java.lang.CharSequence title, java.lang.String customAction, Bundle extras)

Creates a for a notification with a custom action.

public NotificationCompat.ActioncreateCustomActionFromCustomCommandButton(MediaSession mediaSession, CommandButton customCommandButton)

Creates a for a notification from a custom command button.

public NotificationCompat.ActioncreateMediaAction(MediaSession mediaSession, IconCompat icon, java.lang.CharSequence title, int command)

Creates a for a notification.

public PendingIntentcreateMediaActionPendingIntent(MediaSession mediaSession, long command)

Creates a PendingIntent for a media action that will be handled by the library.

Methods

public NotificationCompat.Action createMediaAction(MediaSession mediaSession, IconCompat icon, java.lang.CharSequence title, int command)

Creates a for a notification. These actions will be handled by the library.

Parameters:

mediaSession: The media session to which the action will be sent.
icon: The icon to show for this action.
title: The title of the action.
command: A command to send when users trigger this action.

public NotificationCompat.Action createCustomAction(MediaSession mediaSession, IconCompat icon, java.lang.CharSequence title, java.lang.String customAction, Bundle extras)

Creates a for a notification with a custom action. Actions created with this method are not expected to be handled by the library and will be forwarded to the notification provider that provided them.

Parameters:

mediaSession: The media session to which the action will be sent.
icon: The icon to show for this action.
title: The title of the action.
customAction: The custom action set.
extras: Extras to be included in the action.

See also: MediaNotification.Provider.handleCustomCommand(MediaSession, String, Bundle)

public NotificationCompat.Action createCustomActionFromCustomCommandButton(MediaSession mediaSession, CommandButton customCommandButton)

Creates a for a notification from a custom command button. Actions created with this method are not expected to be handled by the library and will be forwarded to the notification provider that provided them.

The returned will have a PendingIntent with the extras from SessionCommand.customExtras. Accordingly the command's extras will be passed to MediaNotification.Provider.handleCustomCommand(MediaSession, String, Bundle) when the action is executed.

Parameters:

mediaSession: The media session to which the action will be sent.
customCommandButton: A custom command button.

See also: MediaNotification.Provider.handleCustomCommand(MediaSession, String, Bundle)

public PendingIntent createMediaActionPendingIntent(MediaSession mediaSession, long command)

Creates a PendingIntent for a media action that will be handled by the library.

Parameters:

mediaSession: The media session to which the action will be sent.
command: The intent's command.