MediaNotification.ActionFactory


@UnstableApi
public interface MediaNotification.ActionFactory


Creates actions 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

Public methods

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

Creates a NotificationCompat.Action for a notification with a custom action.

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

Creates a NotificationCompat.Action for a notification from a custom command button.

abstract NotificationCompat.Action
createMediaAction(
    MediaSession mediaSession,
    IconCompat icon,
    CharSequence title,
    @Player.Command int command
)

Creates a NotificationCompat.Action for a notification.

abstract PendingIntent
createMediaActionPendingIntent(
    MediaSession mediaSession,
    @Player.Command long command
)

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

Public methods

createCustomAction

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

Creates a NotificationCompat.Action 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 mediaSession

The media session to which the action will be sent.

IconCompat icon

The icon to show for this action.

CharSequence title

The title of the action.

String customAction

The custom action set.

Bundle extras

Extras to be included in the action.

createCustomActionFromCustomCommandButton

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

Creates a NotificationCompat.Action 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 NotificationCompat.Action will have a PendingIntent with the extras from customExtras. Accordingly the command's extras will be passed to handleCustomCommand when the action is executed.

Parameters
MediaSession mediaSession

The media session to which the action will be sent.

CommandButton customCommandButton

A custom command button.

createMediaAction

abstract NotificationCompat.Action createMediaAction(
    MediaSession mediaSession,
    IconCompat icon,
    CharSequence title,
    @Player.Command int command
)

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

Parameters
MediaSession mediaSession

The media session to which the action will be sent.

IconCompat icon

The icon to show for this action.

CharSequence title

The title of the action.

@Player.Command int command

A command to send when users trigger this action.

createMediaActionPendingIntent

abstract PendingIntent createMediaActionPendingIntent(
    MediaSession mediaSession,
    @Player.Command long command
)

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

Parameters
MediaSession mediaSession

The media session to which the action will be sent.

@Player.Command long command

The intent's command.