MediaNotificationService

public classMediaNotificationServiceextendsService

A service to provide status bar notifications when casting. This service will start when a media session begins, and will stop when the media session ends. This service builds media-style notification, which includes an album art image, a title and up to 5 action buttons, based on the options provided inNotificationOptions.

The album art image is picked from the list of images of theMediaMetadata of the current item. If CastMediaOptions.getImagePicker()is provided it will be used to pick the image, with the type ImagePicker.IMAGE_TYPE_NOTIFICATION_THUMBNAIL.If no image is available, R.drawable.cast_album_art_placeholderand R.drawable.cast_album_art_placeholder_largewill be used, depending on the screen size. They can be overridden by the application.

The title is set to the value keyed byMediaMetadata.KEY_TITLE in the metadata of the current item.

The list of action buttons is set to NotificationOptions.getActions(),seeMediaIntentReceiver for the list of available actions.

The notification icon in the status bar is set to R.drawable.cast_ic_notification_small_icon.This can be overridden by the application.

Constant Summary

String ACTION_UPDATE_NOTIFICATION The action for updating the notification.

Inherited Constant Summary

Public Constructor Summary

Public Method Summary

static boolean
isNotificationOptionsValid(CastOptions options)
Returns true if NotificationOptionsin theCastOptions provides valid actions.
IBinder
onBind(Intent intent)
void
void
int
onStartCommand(Intent intent, int flags, int startId)

Inherited Method Summary

Constants

public static finalString ACTION_UPDATE_NOTIFICATION

The action for updating the notification.

Constant Value: "com.google.android.gms.cast.framework.action.UPDATE_NOTIFICATION"

Public Constructors

publicMediaNotificationService()

Public Methods

public static booleanisNotificationOptionsValid(CastOptions options)

Returns true if NotificationOptionsin theCastOptions provides valid actions.

publicIBinderonBind(Intent intent)

public voidonCreate()

public voidonDestroy()

public intonStartCommand(Intentintent, int flags, int startId)