Stay organized with collections Save and categorize content based on your preferences.

PlayerNotificationManager.CustomActionReceiver

interface PlayerNotificationManager.CustomActionReceiver


Defines and handles custom actions.

Summary

Public functions

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

Gets the actions handled by this receiver.

(Mutable)List<String!>!

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

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

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 instances are in use at the same time, the instanceId must be set as an intent extra with key 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 attributes considered by filterEquals, or different request code integers when creating the PendingIntents with getBroadcast. The easiest approach is to use the instanceId as the request code.

Parameters
context: Context!

The Context.

instanceId: Int

The instance id of the PlayerNotificationManager.

Returns
(Mutable)Map<String!, 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!

The Player for which a notification is being built.

Returns
(Mutable)List<String!>!

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!

The player.

action: String!

The action from getAction.

intent: Intent!

The received Intent.