# PlayerNotificationManager.CustomActionReceiver

Artifact: [androidx.media3:media3-ui](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/ui/PlayerNotificationManager.java+class:androidx.media3.ui.PlayerNotificationManager.CustomActionReceiver)

*** ** * ** ***


```
public interface PlayerNotificationManager.CustomActionReceiver
```

<br />

*** ** * ** ***

Defines and handles custom actions.

## Summary

| ### Public methods |
|---|---|
| `abstract https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action>` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver#createCustomActions(android.content.Context,int)(https://developer.android.com/reference/android/content/Context.html context, int instanceId)` Gets the actions handled by this receiver. |
| `abstract https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver#getCustomActions(androidx.media3.common.Player)(https://developer.android.com/reference/androidx/media3/common/Player player)` Gets the actions to be included in the notification given the current player state. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver#onCustomAction(androidx.media3.common.Player,java.lang.String,android.content.Intent)(https://developer.android.com/reference/androidx/media3/common/Player player, https://developer.android.com/reference/java/lang/String.html action, https://developer.android.com/reference/android/content/Intent.html intent)` Called when a custom action has been received. |

## Public methods

### createCustomActions

```
abstract Map<String, NotificationCompat.Action> createCustomActions(Context context, int instanceId)
```

Gets the actions handled by this receiver.

If multiple `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager` instances are in use at the same time, the `instanceId` must be set as an intent extra with key `https://developer.android.com/reference/androidx/media3/ui/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 `https://developer.android.com/reference/android/content/Intent.html` attributes considered by `https://developer.android.com/reference/android/content/Intent.html#filterEquals(android.content.Intent)`, or different request code integers when creating the `https://developer.android.com/reference/android/app/PendingIntent.html`s with `https://developer.android.com/reference/android/app/PendingIntent.html#getBroadcast(android.content.Context, int, android.content.Intent, int)`. The easiest approach is to use the `instanceId` as the request code.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `int instanceId` | The instance id of the `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action>` | A map of custom actions. |

### getCustomActions

```
abstract List<String> getCustomActions(Player player)
```

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player` for which a notification is being built. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | The actions to be included in the notification. |

### onCustomAction

```
abstract void onCustomAction(Player player, String action, Intent intent)
```

Called when a custom action has been received.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The player. |
| `https://developer.android.com/reference/java/lang/String.html action` | The action from `https://developer.android.com/reference/android/content/Intent.html#getAction()`. |
| `https://developer.android.com/reference/android/content/Intent.html intent` | The received `https://developer.android.com/reference/android/content/Intent.html`. |