# PlayerNotificationManager.CustomActionReceiver

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver "View this page in Java")

<br />

```
interface PlayerNotificationManager.CustomActionReceiver
```

<br />

*** ** * ** ***

Defines and handles custom actions.

## Summary

|                                                                                                                                                                                                 ### Public functions                                                                                                                                                                                                  |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)`)`[Map](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!, `[NotificationCompat.Action](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action)`!>!` | [createCustomActions](https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver#createCustomActions(android.content.Context,int))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, instanceId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Gets the actions handled by this receiver.                                                                                                                                        |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!>!`                                                                                                                          | [getCustomActions](https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver#getCustomActions(androidx.media3.common.Player))`(player: `[Player](https://developer.android.com/reference/kotlin/androidx/media3/common/Player)`!)` Gets the actions to be included in the notification given the current player state.                                                                                                                                                                                        |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                                                                                                                                                                                                                                         | [onCustomAction](https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver#onCustomAction(androidx.media3.common.Player,java.lang.String,android.content.Intent))`(player: `[Player](https://developer.android.com/reference/kotlin/androidx/media3/common/Player)`!, action: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!, intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`!)` Called when a custom action has been received. |

## Public functions

### createCustomActions

```
fun createCustomActions(context: Context!, instanceId: Int): (Mutable)Map<String!, NotificationCompat.Action!>!
```

Gets the actions handled by this receiver.

If multiple[PlayerNotificationManager](https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager)instances are in use at the same time, the`instanceId`must be set as an intent extra with key[EXTRA_INSTANCE_ID](https://developer.android.com/reference/kotlin/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[Intent](https://developer.android.com/reference/android/content/Intent.html)attributes considered by[filterEquals](https://developer.android.com/reference/android/content/Intent.html#filterEquals(android.content.Intent)), or different request code integers when creating the[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)s with[getBroadcast](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                                           |
|-----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | The[Context](https://developer.android.com/reference/android/content/Context.html).                                                             |
| `instanceId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)     | The instance id of the[PlayerNotificationManager](https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager). |

|                                                                                                                                                                                                        Returns                                                                                                                                                                                                        |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)`)`[Map](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!, `[NotificationCompat.Action](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action)`!>!` | A map of custom actions. |

### getCustomActions

```
fun getCustomActions(player: Player!): (Mutable)List<String!>!
```

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

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

|                                                                                                                                           Returns                                                                                                                                            |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!>!` | The actions to be included in the notification. |

### onCustomAction

```
fun onCustomAction(player: Player!, action: String!, intent: Intent!): Unit
```

Called when a custom action has been received.  

|                                             Parameters                                              |
|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
| `player: `[Player](https://developer.android.com/reference/kotlin/androidx/media3/common/Player)`!` | The player.                                                                                                  |
| `action: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`      | The action from[getAction](https://developer.android.com/reference/android/content/Intent.html#getAction()). |
| `intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`!`          | The received[Intent](https://developer.android.com/reference/android/content/Intent.html).                   |