NotificationOptions.Builder

public static final class NotificationOptions.Builder extends Object

A builder for creating an instance of NotificationOptions.

Public Constructor Summary

Public Method Summary

NotificationOptions
build()
Builds and returns the NotificationOptions object.
NotificationOptions.Builder
setActions(List<String> actions, int[] compatActionIndices)
Sets at most 5 actions to show in the notification, and the indices to the actions to show in the compact view.
NotificationOptions.Builder
setDisconnectDrawableResId(int resId)
Sets the resource ID of the icon that indicates "disconnect".
NotificationOptions.Builder
setForward10DrawableResId(int resId)
Sets the resource ID of the icon that indicates "skip forward 10 seconds".
NotificationOptions.Builder
setForward30DrawableResId(int resId)
Sets the resource ID of the icon that indicates "skip forward 30 seconds".
NotificationOptions.Builder
setForwardDrawableResId(int resId)
Sets the resource ID of the icon that indicates "skip forward".
NotificationOptions.Builder
setNotificationActionsProvider(NotificationActionsProvider notificationActionsProvider)
Sets a NotificationActionsProvider, which can be subclassed to provide dynamic custom actions.
NotificationOptions.Builder
setPauseDrawableResId(int resId)
Sets the resource ID of the icon that indicates "pause".
NotificationOptions.Builder
setPlayDrawableResId(int resId)
Sets the resource ID of the icon that indicates "play".
NotificationOptions.Builder
setRewind10DrawableResId(int resId)
Sets the resource ID of the icon that indicates "rewind 10 seconds".
NotificationOptions.Builder
setRewind30DrawableResId(int resId)
Sets the resource ID of the icon that indicates "rewind 30 seconds".
NotificationOptions.Builder
setRewindDrawableResId(int resId)
Sets the resource ID of the icon that indicates "rewind".
NotificationOptions.Builder
setSkipNextDrawableResId(int resId)
Sets the resource ID of the icon that indicates "skip next".
NotificationOptions.Builder
setSkipPrevDrawableResId(int resId)
Sets the resource ID of the icon that indicates "skip previous".
NotificationOptions.Builder
setSkipStepMs(long notificationSkipStepMs)
Sets the amount to jump if MediaIntentReceiver.ACTION_FORWARD or MediaIntentReceiver.ACTION_REWIND are included for the notification actions.
NotificationOptions.Builder
setSkipToNextSlotReserved(boolean skipToNextSlotReserved)
Sets true to reserve the slot of skip-to-next action for Android T or above.
NotificationOptions.Builder
setSkipToPrevSlotReserved(boolean skipToPrevSlotReserved)
Sets true to reserve the slot of skip-to-previous action for Android T or above.
NotificationOptions.Builder
setSmallIconDrawableResId(int resId)
Sets the resource ID for the notification icon drawable.
NotificationOptions.Builder
setStopLiveStreamDrawableResId(int resId)
Sets the resource ID of the icon that indicates "stop playing live stream".
NotificationOptions.Builder
setTargetActivityClassName(String className)
Sets the name of the Activity that will be launched when user taps on the content area of the notification.

Inherited Method Summary

Public Constructors

public Builder ()

Public Methods

public NotificationOptions build ()

Builds and returns the NotificationOptions object.

public NotificationOptions.Builder setActions (List<String> actions, int[] compatActionIndices)

Sets at most 5 actions to show in the notification, and the indices to the actions to show in the compact view. If both actions and compatActionIndices are null, the default values, MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK and MediaIntentReceiver.ACTION_STOP_CASTING will be used.

The list of actions that can be set through this method is defined in MediaIntentReceiver. To provide a dynamic custom action, set a NotificationActionsProvider using the setNotificationActionsProvider(NotificationActionsProvider) method below. If a NotificationActionsProvider is set, the SDK will use it to get the list of actions and the indices that should appear in the compact view, instead of the values provided here. See NotificationActionsProvider for how to implement dynamic custom actions.

Parameters
actions The list of actions, defined in MediaIntentReceiver.
compatActionIndices Indices of the actions in the actions list, which will be shown in the compact view.
Throws
IllegalArgumentException If actions and compatActionIndices are not either both null or non-null, or if the length of compatActionIndices is greater than the size of actions, or if any index in compatActionIndices is out of range.

public NotificationOptions.Builder setDisconnectDrawableResId (int resId)

Sets the resource ID of the icon that indicates "disconnect". By default, a drawable ic_notification_disconnect.xml from the SDK is used.

public NotificationOptions.Builder setForward10DrawableResId (int resId)

Sets the resource ID of the icon that indicates "skip forward 10 seconds". By default, a drawable ic_notification_forward10.xml from the SDK is used.

public NotificationOptions.Builder setForward30DrawableResId (int resId)

Sets the resource ID of the icon that indicates "skip forward 30 seconds". By default, a drawable ic_notification_forward30.xml from the SDK is used.

public NotificationOptions.Builder setForwardDrawableResId (int resId)

Sets the resource ID of the icon that indicates "skip forward". By default, a drawable ic_notification_forward.xml from the SDK is used.

public NotificationOptions.Builder setNotificationActionsProvider (NotificationActionsProvider notificationActionsProvider)

Sets a NotificationActionsProvider, which can be subclassed to provide dynamic custom actions. If set, the SDK will use it to get the list of actions and the indices that should appear in the compact view. If not set, the SDK will use the value provided by the call to setActions(List, int[]).

See MediaIntentReceiver for a list of predefined actions that you can use to implement your NotificationActionsProvider. See NotificationActionsProvider for how to implement custom actions.

Parameters
notificationActionsProvider The NotificationActionsProvider that provides the list of NotificationAction that should appear in the expanded view and indices of actions that should appear in the compact view.
Throws
IllegalArgumentException If notificationActionsProvider is null.

public NotificationOptions.Builder setPauseDrawableResId (int resId)

Sets the resource ID of the icon that indicates "pause". By default, a drawable ic_notification_pause.xml from the SDK is used.

public NotificationOptions.Builder setPlayDrawableResId (int resId)

Sets the resource ID of the icon that indicates "play". By default, a drawable ic_notification_play.xml from the SDK is used.

public NotificationOptions.Builder setRewind10DrawableResId (int resId)

Sets the resource ID of the icon that indicates "rewind 10 seconds". By default, a drawable ic_notification_rewind10.xml from the SDK is used.

public NotificationOptions.Builder setRewind30DrawableResId (int resId)

Sets the resource ID of the icon that indicates "rewind 30 seconds". By default, a drawable ic_notification_rewind30.xml from the SDK is used.

public NotificationOptions.Builder setRewindDrawableResId (int resId)

Sets the resource ID of the icon that indicates "rewind". By default, a drawable ic_notification_rewind.xml from the SDK is used.

public NotificationOptions.Builder setSkipNextDrawableResId (int resId)

Sets the resource ID of the icon that indicates "skip next". By default, a drawable ic_notification_skip_next.xml from the SDK is used.

public NotificationOptions.Builder setSkipPrevDrawableResId (int resId)

Sets the resource ID of the icon that indicates "skip previous". By default, a drawable ic_notification_skip_prev.xml from the SDK is used.

public NotificationOptions.Builder setSkipStepMs (long notificationSkipStepMs)

Sets the amount to jump if MediaIntentReceiver.ACTION_FORWARD or MediaIntentReceiver.ACTION_REWIND are included for the notification actions. Any tap on those actions will result in moving the media position forward or backward by notificationSkipStepMs milliseconds. The default value is NotificationOptions.SKIP_STEP_TEN_SECONDS_IN_MS.

Parameters
notificationSkipStepMs The amount of time to skip, in milliseconds.
Throws
IllegalArgumentException if notificationSkipStepMs is not positive.

public NotificationOptions.Builder setSkipToNextSlotReserved (boolean skipToNextSlotReserved)

Sets true to reserve the slot of skip-to-next action for Android T or above.

Parameters
skipToNextSlotReserved if the slot of skip-to-next action is reserved

public NotificationOptions.Builder setSkipToPrevSlotReserved (boolean skipToPrevSlotReserved)

Sets true to reserve the slot of skip-to-previous action for Android T or above.

Parameters
skipToPrevSlotReserved if the slot of skip-to-previous action is reserved

public NotificationOptions.Builder setSmallIconDrawableResId (int resId)

Sets the resource ID for the notification icon drawable. By default, a drawable ic_notification_small_icon.xml from the SDK is used.

public NotificationOptions.Builder setStopLiveStreamDrawableResId (int resId)

Sets the resource ID of the icon that indicates "stop playing live stream". By default, a drawable ic_notification_stop_live_stream.xml from the SDK is used.

public NotificationOptions.Builder setTargetActivityClassName (String className)

Sets the name of the Activity that will be launched when user taps on the content area of the notification. If set to null then clicking on the content area will not launch any Activity. The default value is null.