PlayerNotificationManager.Builder


public class PlayerNotificationManager.Builder


A builder for PlayerNotificationManager instances.

Summary

Public constructors

Builder(
    Context context,
    @IntRange(from = 1) int notificationId,
    String channelId
)

Creates an instance.

Builder(
    Context context,
    int notificationId,
    String channelId,
    PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter
)

This method is deprecated.

Use Builder instead, then call setMediaDescriptionAdapter.

Public methods

PlayerNotificationManager

Builds the PlayerNotificationManager.

PlayerNotificationManager.Builder
setChannelDescriptionResourceId(int channelDescriptionResourceId)

The description of the channel.

PlayerNotificationManager.Builder

The importance of the channel.

PlayerNotificationManager.Builder
setChannelNameResourceId(int channelNameResourceId)

The name of the channel.

PlayerNotificationManager.Builder

The CustomActionReceiver to be used.

PlayerNotificationManager.Builder
setFastForwardActionIconResourceId(
    int fastForwardActionIconResourceId
)

The resource id of the drawable to be used as the icon of action ACTION_FAST_FORWARD.

PlayerNotificationManager.Builder
setGroup(String groupKey)

The key of the group the media notification should belong to.

PlayerNotificationManager.Builder

The MediaDescriptionAdapter to be queried for the notification contents.

PlayerNotificationManager.Builder
setNextActionIconResourceId(int nextActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_NEXT.

PlayerNotificationManager.Builder

The NotificationListener to be used.

PlayerNotificationManager.Builder
setPauseActionIconResourceId(int pauseActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_PAUSE.

PlayerNotificationManager.Builder
setPlayActionIconResourceId(int playActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_PLAY.

PlayerNotificationManager.Builder
setPreviousActionIconResourceId(int previousActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_PREVIOUS.

PlayerNotificationManager.Builder
setRewindActionIconResourceId(int rewindActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_REWIND.

PlayerNotificationManager.Builder
setSmallIconResourceId(int smallIconResourceId)

The resource id of the small icon of the notification shown in the status bar.

PlayerNotificationManager.Builder
setStopActionIconResourceId(int stopActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_STOP.

Protected fields

channelDescriptionResourceId

protected int channelDescriptionResourceId

channelId

protected final String channelId

channelImportance

protected int channelImportance

channelNameResourceId

protected int channelNameResourceId

context

protected final Context context

fastForwardActionIconResourceId

protected int fastForwardActionIconResourceId

groupKey

protected @Nullable String groupKey

nextActionIconResourceId

protected int nextActionIconResourceId

notificationId

protected final int notificationId

pauseActionIconResourceId

protected int pauseActionIconResourceId

playActionIconResourceId

protected int playActionIconResourceId

previousActionIconResourceId

protected int previousActionIconResourceId

rewindActionIconResourceId

protected int rewindActionIconResourceId

smallIconResourceId

protected int smallIconResourceId

stopActionIconResourceId

protected int stopActionIconResourceId

Public constructors

Builder

public Builder(
    Context context,
    @IntRange(from = 1) int notificationId,
    String channelId
)

Creates an instance.

Parameters
Context context

The Context.

@IntRange(from = 1) int notificationId

The id of the notification to be posted. Must be greater than 0.

String channelId

The id of the notification channel of an existing notification channel or of the channel that should be automatically created. In the latter case, setChannelNameResourceId needs to be called as well.

Builder

public Builder(
    Context context,
    int notificationId,
    String channelId,
    PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter
)

Public methods

setChannelDescriptionResourceId

public PlayerNotificationManager.Builder setChannelDescriptionResourceId(int channelDescriptionResourceId)

The description of the channel. Ignored if setChannelNameResourceId is not called with a value other than 0. If the application has already created the notification channel, then this method should not be called.

The default is 0.

Returns
PlayerNotificationManager.Builder

This builder.

setChannelImportance

public PlayerNotificationManager.Builder setChannelImportance(@NotificationUtil.Importance int channelImportance)

The importance of the channel. Ignored if setChannelNameResourceId is not called with a value other than 0. If the application has already created the notification channel, then this method should not be called.

The default is IMPORTANCE_LOW.

Returns
PlayerNotificationManager.Builder

This builder.

setChannelNameResourceId

public PlayerNotificationManager.Builder setChannelNameResourceId(int channelNameResourceId)

The name of the channel. If set to a value other than 0, the channel is automatically created when build is called. If the application has already created the notification channel, then this method should not be called.

The default is 0.

Returns
PlayerNotificationManager.Builder

This builder.

setCustomActionReceiver

public PlayerNotificationManager.Builder setCustomActionReceiver(
    PlayerNotificationManager.CustomActionReceiver customActionReceiver
)

The CustomActionReceiver to be used.

The default is null.

Returns
PlayerNotificationManager.Builder

This builder.

setFastForwardActionIconResourceId

public PlayerNotificationManager.Builder setFastForwardActionIconResourceId(
    int fastForwardActionIconResourceId
)

The resource id of the drawable to be used as the icon of action ACTION_FAST_FORWARD.

The default is R.drawable#exo_notification_fastforward.

Returns
PlayerNotificationManager.Builder

This builder.

setGroup

public PlayerNotificationManager.Builder setGroup(String groupKey)

The key of the group the media notification should belong to.

The default is null

Returns
PlayerNotificationManager.Builder

This builder.

setMediaDescriptionAdapter

public PlayerNotificationManager.Builder setMediaDescriptionAdapter(
    PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter
)

The MediaDescriptionAdapter to be queried for the notification contents.

The default is DefaultMediaDescriptionAdapter with no PendingIntent

Returns
PlayerNotificationManager.Builder

This builder.

setNextActionIconResourceId

public PlayerNotificationManager.Builder setNextActionIconResourceId(int nextActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_NEXT.

The default is R.drawable#exo_notification_next.

Returns
PlayerNotificationManager.Builder

This builder.

setNotificationListener

public PlayerNotificationManager.Builder setNotificationListener(
    PlayerNotificationManager.NotificationListener notificationListener
)

The NotificationListener to be used.

The default is null.

Returns
PlayerNotificationManager.Builder

This builder.

setPauseActionIconResourceId

public PlayerNotificationManager.Builder setPauseActionIconResourceId(int pauseActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_PAUSE.

The default is R.drawable#exo_notification_pause.

Returns
PlayerNotificationManager.Builder

This builder.

setPlayActionIconResourceId

public PlayerNotificationManager.Builder setPlayActionIconResourceId(int playActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_PLAY.

The default is R.drawable#exo_notification_play.

Returns
PlayerNotificationManager.Builder

This builder.

setPreviousActionIconResourceId

public PlayerNotificationManager.Builder setPreviousActionIconResourceId(int previousActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_PREVIOUS.

The default is R.drawable#exo_notification_previous.

Returns
PlayerNotificationManager.Builder

This builder.

setRewindActionIconResourceId

public PlayerNotificationManager.Builder setRewindActionIconResourceId(int rewindActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_REWIND.

The default is R.drawable#exo_notification_rewind.

Returns
PlayerNotificationManager.Builder

This builder.

setSmallIconResourceId

public PlayerNotificationManager.Builder setSmallIconResourceId(int smallIconResourceId)

The resource id of the small icon of the notification shown in the status bar. See setSmallIcon.

The default is R.drawable#exo_notification_small_icon.

Returns
PlayerNotificationManager.Builder

This builder.

setStopActionIconResourceId

public PlayerNotificationManager.Builder setStopActionIconResourceId(int stopActionIconResourceId)

The resource id of the drawable to be used as the icon of action ACTION_STOP.

The default is R.drawable#exo_notification_stop.

Returns
PlayerNotificationManager.Builder

This builder.