RoutingSessionInfo.Builder


public static final class RoutingSessionInfo.Builder
extends Object

java.lang.Object
   ↳ android.media.RoutingSessionInfo.Builder


Builder class for RoutingSessionInfo.

Summary

Public constructors

Builder(String id, String clientPackageName)

Constructor for builder to create RoutingSessionInfo.

Builder(RoutingSessionInfo sessionInfo)

Constructor for builder to create RoutingSessionInfo with existing RoutingSessionInfo instance.

Public methods

RoutingSessionInfo.Builder addDeselectableRoute(String routeId)

Adds a route to the deselectable routes.

RoutingSessionInfo.Builder addSelectableRoute(String routeId)

Adds a route to the selectable routes.

RoutingSessionInfo.Builder addSelectedRoute(String routeId)

Adds a route to the selected routes.

RoutingSessionInfo.Builder addTransferableRoute(String routeId)

Adds a route to the transferable routes.

RoutingSessionInfo build()

Builds a routing session info.

RoutingSessionInfo.Builder clearDeselectableRoutes()

Clears the deselectable routes.

RoutingSessionInfo.Builder clearSelectableRoutes()

Clears the selectable routes.

RoutingSessionInfo.Builder clearSelectedRoutes()

Clears the selected routes.

RoutingSessionInfo.Builder clearTransferableRoutes()

Clears the transferable routes.

RoutingSessionInfo.Builder removeDeselectableRoute(String routeId)

Removes a route from the deselectable routes.

RoutingSessionInfo.Builder removeSelectableRoute(String routeId)

Removes a route from the selectable routes.

RoutingSessionInfo.Builder removeSelectedRoute(String routeId)

Removes a route from the selected routes.

RoutingSessionInfo.Builder removeTransferableRoute(String routeId)

Removes a route from the transferable routes.

RoutingSessionInfo.Builder setControlHints(Bundle controlHints)

Sets control hints.

RoutingSessionInfo.Builder setName(CharSequence name)

Sets the user-visible name of the session.

RoutingSessionInfo.Builder setTransferInitiator(UserHandle transferInitiatorUserHandle, String transferInitiatorPackageName)

Sets the user handle and package name of the process that initiated the transfer.

RoutingSessionInfo.Builder setTransferReason(int transferReason)

Sets transfer reason for the current session.

RoutingSessionInfo.Builder setVolume(int volume)

Sets the session's current volume, or 0 if unknown.

RoutingSessionInfo.Builder setVolumeHandling(int volumeHandling)

Sets the session's volume handling.

RoutingSessionInfo.Builder setVolumeMax(int volumeMax)

Sets the session's maximum volume, or 0 if unknown.

Inherited methods

Public constructors

Builder

Added in API level 30
public Builder (String id, 
                String clientPackageName)

Constructor for builder to create RoutingSessionInfo.

In order to ensure ID uniqueness in MediaRouter2 side, the value of RoutingSessionInfo#getId() can be different from what was set in MediaRoute2ProviderService.

Parameters
id String: ID of the session. Must not be empty. This value cannot be null.

clientPackageName String: package name of the client app which uses this session. If is is unknown, then just use an empty string. This value cannot be null.

Builder

Added in API level 30
public Builder (RoutingSessionInfo sessionInfo)

Constructor for builder to create RoutingSessionInfo with existing RoutingSessionInfo instance.

Parameters
sessionInfo RoutingSessionInfo: the existing instance to copy data from. This value cannot be null.

Public methods

addDeselectableRoute

Added in API level 30
public RoutingSessionInfo.Builder addDeselectableRoute (String routeId)

Adds a route to the deselectable routes. The routeId must not be empty.

Parameters
routeId String: This value cannot be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

addSelectableRoute

Added in API level 30
public RoutingSessionInfo.Builder addSelectableRoute (String routeId)

Adds a route to the selectable routes. The routeId must not be empty.

Parameters
routeId String: This value cannot be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

addSelectedRoute

Added in API level 30
public RoutingSessionInfo.Builder addSelectedRoute (String routeId)

Adds a route to the selected routes. The routeId must not be empty.

Parameters
routeId String: This value cannot be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

addTransferableRoute

Added in API level 30
public RoutingSessionInfo.Builder addTransferableRoute (String routeId)

Adds a route to the transferable routes. The routeId must not be empty.

Parameters
routeId String: This value cannot be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

build

Added in API level 30
public RoutingSessionInfo build ()

Builds a routing session info.

Returns
RoutingSessionInfo This value cannot be null.

Throws
IllegalArgumentException if no selected routes are added.

clearDeselectableRoutes

Added in API level 30
public RoutingSessionInfo.Builder clearDeselectableRoutes ()

Clears the deselectable routes.

Returns
RoutingSessionInfo.Builder This value cannot be null.

clearSelectableRoutes

Added in API level 30
public RoutingSessionInfo.Builder clearSelectableRoutes ()

Clears the selectable routes.

Returns
RoutingSessionInfo.Builder This value cannot be null.

clearSelectedRoutes

Added in API level 30
public RoutingSessionInfo.Builder clearSelectedRoutes ()

Clears the selected routes.

Returns
RoutingSessionInfo.Builder This value cannot be null.

clearTransferableRoutes

Added in API level 30
public RoutingSessionInfo.Builder clearTransferableRoutes ()

Clears the transferable routes.

Returns
RoutingSessionInfo.Builder This value cannot be null.

removeDeselectableRoute

Added in API level 30
public RoutingSessionInfo.Builder removeDeselectableRoute (String routeId)

Removes a route from the deselectable routes. The routeId must not be empty.

Parameters
routeId String: This value cannot be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

removeSelectableRoute

Added in API level 30
public RoutingSessionInfo.Builder removeSelectableRoute (String routeId)

Removes a route from the selectable routes. The routeId must not be empty.

Parameters
routeId String: This value cannot be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

removeSelectedRoute

Added in API level 30
public RoutingSessionInfo.Builder removeSelectedRoute (String routeId)

Removes a route from the selected routes. The routeId must not be empty.

Parameters
routeId String: This value cannot be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

removeTransferableRoute

Added in API level 30
public RoutingSessionInfo.Builder removeTransferableRoute (String routeId)

Removes a route from the transferable routes. The routeId must not be empty.

Parameters
routeId String: This value cannot be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

setControlHints

Added in API level 30
public RoutingSessionInfo.Builder setControlHints (Bundle controlHints)

Sets control hints.

Parameters
controlHints Bundle: This value may be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

setName

Added in API level 30
public RoutingSessionInfo.Builder setName (CharSequence name)

Sets the user-visible name of the session.

Parameters
name CharSequence: This value may be null.

Returns
RoutingSessionInfo.Builder This value cannot be null.

setTransferInitiator

Added in API level 35
public RoutingSessionInfo.Builder setTransferInitiator (UserHandle transferInitiatorUserHandle, 
                String transferInitiatorPackageName)

Sets the user handle and package name of the process that initiated the transfer.

By default the transfer initiation user handle and package name are set to null.

Parameters
transferInitiatorUserHandle UserHandle: This value may be null.

transferInitiatorPackageName String: This value may be null.

Returns
RoutingSessionInfo.Builder

setTransferReason

Added in API level 35
public RoutingSessionInfo.Builder setTransferReason (int transferReason)

Sets transfer reason for the current session.

By default the transfer reason is set to RoutingSessionInfo.TRANSFER_REASON_FALLBACK.

Parameters
transferReason int: Value is RoutingSessionInfo.TRANSFER_REASON_FALLBACK, RoutingSessionInfo.TRANSFER_REASON_SYSTEM_REQUEST, or RoutingSessionInfo.TRANSFER_REASON_APP

Returns
RoutingSessionInfo.Builder This value cannot be null.

setVolume

Added in API level 30
public RoutingSessionInfo.Builder setVolume (int volume)

Sets the session's current volume, or 0 if unknown.

Parameters
volume int

Returns
RoutingSessionInfo.Builder This value cannot be null.

setVolumeHandling

Added in API level 30
public RoutingSessionInfo.Builder setVolumeHandling (int volumeHandling)

Sets the session's volume handling. MediaRoute2Info#PLAYBACK_VOLUME_FIXED or MediaRoute2Info#PLAYBACK_VOLUME_VARIABLE.

Parameters
volumeHandling int: Value is MediaRoute2Info.PLAYBACK_VOLUME_FIXED, or MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE

Returns
RoutingSessionInfo.Builder This value cannot be null.

setVolumeMax

Added in API level 30
public RoutingSessionInfo.Builder setVolumeMax (int volumeMax)

Sets the session's maximum volume, or 0 if unknown.

Parameters
volumeMax int

Returns
RoutingSessionInfo.Builder This value cannot be null.