public static final class

NotificationOptions.Builder

extends Object
java.lang.Object
   ↳ com.google.android.gms.cast.framework.media.NotificationOptions.Builder

Class Overview

A builder for creating an instance of NotificationOptions.

Summary

Public Constructors
NotificationOptions.Builder()
Public Methods
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 ACTION_FORWARD or ACTION_REWIND are included for the notification actions.
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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public NotificationOptions.Builder ()

Public Methods

public NotificationOptions build ()

Builds and returns the NotificationOptions object.

Returns
NotificationOptions

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, ACTION_TOGGLE_PLAYBACK and 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 List: The list of actions, defined in MediaIntentReceiver.
compatActionIndices int: Indices of the actions in the actions list, which will be shown in the compact view.
Returns
NotificationOptions.Builder
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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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 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.
Returns
NotificationOptions.Builder
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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

public NotificationOptions.Builder setSkipStepMs (long notificationSkipStepMs)

Sets the amount to jump if ACTION_FORWARD or 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 SKIP_STEP_TEN_SECONDS_IN_MS.

Parameters
notificationSkipStepMs long: The amount of time to skip, in milliseconds.
Returns
NotificationOptions.Builder
Throws
IllegalArgumentException if notificationSkipStepMs is not positive.

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
resId int
Returns
NotificationOptions.Builder

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.

Parameters
className String
Returns
NotificationOptions.Builder