google / google/ExoPlayer

Invalidating the notification does not refresh custom actions

Open
#9,468 1 comment 0 reactions 1 assignee Claimed by @marcbaechinger View on GitHub
enhancement low priority
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

I have the following implementation of `PlayerNotificationManager.CustomActionReceiver`

```kotlin
override fun createCustomActions(context: Context, instanceId: Int): MutableMap {
return actions.associate {
val intent = Intent(it.type.value).setPackage(context.packageName)
val action = NotificationCompat.Action(it.icon, it.title, PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT))
it.type.value to action
}.toMutableMap()
}

override fun getCustomActions(player: Player): MutableList {
return actions.map { it.type.value }.toMutableList()
}

override fun onCustomAction(player: Player, action: String, intent: Intent) {
scope.launch {
onCustomAction.emit(NotificationActionType.valueOf(action))
}
}
```

The problem is my `actions` arrive late. Not only that, we would like to support updating the custom actions in runtime. Sadly this doesn't seem possible when calling `PlayerNotificationManager.invalidate()`. `createCustomActions()` never gets called again after calling `invalidate()`. This call seems to refresh everything in the notification, except the custom actions.

Is this a known issue?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.