public class

PlayerNotificationManager.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.session.PlayerNotificationManager.Builder

Overview

A builder for PlayerNotificationManager instances.

Summary

Fields
protected intchannelDescriptionResourceId

protected final java.lang.StringchannelId

protected intchannelImportance

protected intchannelNameResourceId

protected BundleconnectionHints

protected final Contextcontext

protected java.lang.StringgroupKey

protected PlayerNotificationManager.MediaDescriptionAdaptermediaDescriptionAdapter

protected final intnotificationId

protected PlayerNotificationManager.NotificationListenernotificationListener

protected MediaSessionsession

protected intsmallIconResourceId

Constructors
publicBuilder(Context context, MediaSession session, int notificationId, java.lang.String channelId)

Creates an instance.

Methods
public PlayerNotificationManagerbuild()

Builds the PlayerNotificationManager.

public PlayerNotificationManager.BuildersetChannelDescriptionResourceId(int channelDescriptionResourceId)

The description of the channel.

public PlayerNotificationManager.BuildersetChannelImportance(int channelImportance)

The importance of the channel.

public PlayerNotificationManager.BuildersetChannelNameResourceId(int channelNameResourceId)

The name of the channel.

public PlayerNotificationManager.BuildersetConnectionHints(Bundle connectionHints)

The connection hints for identify MediaController to deliver commands from the notification.

public PlayerNotificationManager.BuildersetGroup(java.lang.String groupKey)

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

public PlayerNotificationManager.BuildersetMediaDescriptionAdapter(PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter)

The PlayerNotificationManager.MediaDescriptionAdapter to be queried for the notification contents.

public PlayerNotificationManager.BuildersetNotificationListener(PlayerNotificationManager.NotificationListener notificationListener)

The PlayerNotificationManager.NotificationListener to be used.

public PlayerNotificationManager.BuildersetSmallIconResourceId(int smallIconResourceId)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

protected final Context context

protected final int notificationId

protected final java.lang.String channelId

protected MediaSession session

protected Bundle connectionHints

protected PlayerNotificationManager.NotificationListener notificationListener

protected PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter

protected int channelNameResourceId

protected int channelDescriptionResourceId

protected int channelImportance

protected int smallIconResourceId

protected java.lang.String groupKey

Constructors

public Builder(Context context, MediaSession session, int notificationId, java.lang.String channelId)

Creates an instance.

Parameters:

context: The .
notificationId: The id of the notification to be posted. Must be greater than 0.
session: The session to build notification with.
channelId: The id of the notification channel.

Methods

public PlayerNotificationManager.Builder setConnectionHints(Bundle connectionHints)

The connection hints for identify MediaController to deliver commands from the notification.

Returns:

This builder

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 PlayerNotificationManager.Builder.build() is called. If the application has already created the notification channel, then this method should not be called.

The default is 0.

Returns:

This builder.

public PlayerNotificationManager.Builder setChannelDescriptionResourceId(int channelDescriptionResourceId)

The description of the channel. Ignored if PlayerNotificationManager.Builder.setChannelNameResourceId(int) 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:

This builder.

public PlayerNotificationManager.Builder setChannelImportance(int channelImportance)

The importance of the channel. Ignored if PlayerNotificationManager.Builder.setChannelNameResourceId(int) 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 NotificationUtil.IMPORTANCE_LOW.

Returns:

This builder.

public PlayerNotificationManager.Builder setNotificationListener(PlayerNotificationManager.NotificationListener notificationListener)

The PlayerNotificationManager.NotificationListener to be used.

The default is null.

Returns:

This builder.

public PlayerNotificationManager.Builder setSmallIconResourceId(int smallIconResourceId)

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

The default is R.drawable#media3_notification_small_icon.

Returns:

This builder.

public PlayerNotificationManager.Builder setGroup(java.lang.String groupKey)

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

The default is null

Returns:

This builder.

public PlayerNotificationManager.Builder setMediaDescriptionAdapter(PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter)

The PlayerNotificationManager.MediaDescriptionAdapter to be queried for the notification contents.

The default is DefaultMediaDescriptionAdapter with no PendingIntent

Returns:

This builder.

Builds the PlayerNotificationManager.