public interface

PlayerNotificationManager.CustomActionReceiver

 androidx.media3.ui.PlayerNotificationManager.CustomActionReceiver

Overview

Defines and handles custom actions.

Summary

Methods
public java.util.Map<java.lang.String, NotificationCompat.Action>createCustomActions(Context context, int instanceId)

Gets the actions handled by this receiver.

public java.util.List<java.lang.String>getCustomActions(Player player)

Gets the actions to be included in the notification given the current player state.

public voidonCustomAction(Player player, java.lang.String action, Intent intent)

Called when a custom action has been received.

Methods

public java.util.Map<java.lang.String, NotificationCompat.Action> createCustomActions(Context context, int instanceId)

Gets the actions handled by this receiver.

If multiple PlayerNotificationManager instances are in use at the same time, the instanceId must be set as an intent extra with key PlayerNotificationManager.EXTRA_INSTANCE_ID to avoid sending the action to every custom action receiver. It's also necessary to ensure something is different about the actions. This may be any of the attributes considered by , or different request code integers when creating the PendingIntents with PendingIntent. The easiest approach is to use the instanceId as the request code.

Parameters:

context: The .
instanceId: The instance id of the PlayerNotificationManager.

Returns:

A map of custom actions.

public java.util.List<java.lang.String> getCustomActions(Player player)

Gets the actions to be included in the notification given the current player state.

Parameters:

player: The Player for which a notification is being built.

Returns:

The actions to be included in the notification.

public void onCustomAction(Player player, java.lang.String action, Intent intent)

Called when a custom action has been received.

Parameters:

player: The player.
action: The action from .
intent: The received .