MediaRouteDescriptor.Builder


public final class MediaRouteDescriptor.Builder


Builder for media route descriptors.

Summary

Public constructors

Creates a media route descriptor builder whose initial contents are copied from an existing descriptor.

Creates a media route descriptor builder.

Public methods

@NonNull MediaRouteDescriptor.Builder

Adds a media control intent filter for the route.

@NonNull MediaRouteDescriptor.Builder

Adds a list of media control intent filters for the route.

@NonNull MediaRouteDescriptor

Builds the media route descriptor.

@NonNull MediaRouteDescriptor.Builder

Clears media control intent filters for the route.

@NonNull MediaRouteDescriptor.Builder
setCanDisconnect(boolean canDisconnect)

Sets whether the route can be disconnected without stopping playback.

@NonNull MediaRouteDescriptor.Builder
setConnecting(boolean connecting)

This method is deprecated.

Use setConnectionState instead.

@NonNull MediaRouteDescriptor.Builder
setConnectionState(int connectionState)

Sets the route's connection state.

@NonNull MediaRouteDescriptor.Builder
setDeduplicationIds(@NonNull Set<String> deduplicationIds)

Sets the route's deduplication ids.

@NonNull MediaRouteDescriptor.Builder

Sets the user-visible description of the route.

@NonNull MediaRouteDescriptor.Builder
setDeviceType(int deviceType)

Sets the route's receiver device type.

@NonNull MediaRouteDescriptor.Builder
setEnabled(boolean enabled)

Sets whether the route is enabled.

@NonNull MediaRouteDescriptor.Builder

Sets a bundle of extras for this route descriptor.

@NonNull MediaRouteDescriptor.Builder

Sets the URI of the icon representing this route.

@NonNull MediaRouteDescriptor.Builder

Sets the unique id of the route.

@NonNull MediaRouteDescriptor.Builder
setIsDynamicGroupRoute(boolean isDynamicGroupRoute)

Sets whether the route is a dynamic group route.

@NonNull MediaRouteDescriptor.Builder

Sets the user-visible name of the route.

@NonNull MediaRouteDescriptor.Builder
setPlaybackStream(int playbackStream)

Sets the route's playback stream.

@NonNull MediaRouteDescriptor.Builder
setPlaybackType(int playbackType)

Sets the route's playback type.

@NonNull MediaRouteDescriptor.Builder
setPresentationDisplayId(int presentationDisplayId)

Sets the route's presentation display id, or -1 if none.

@NonNull MediaRouteDescriptor.Builder

Sets an intent sender for launching the settings activity for this route.

@NonNull MediaRouteDescriptor.Builder

Sets the visibility of this route to public.

@NonNull MediaRouteDescriptor.Builder

Sets the visibility of this route to restricted.

@NonNull MediaRouteDescriptor.Builder
setVolume(int volume)

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

@NonNull MediaRouteDescriptor.Builder
setVolumeHandling(int volumeHandling)

Sets the route's volume handling.

@NonNull MediaRouteDescriptor.Builder
setVolumeMax(int volumeMax)

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

Public constructors

Builder

Added in 1.1.0
public Builder(@NonNull MediaRouteDescriptor descriptor)

Creates a media route descriptor builder whose initial contents are copied from an existing descriptor.

Builder

Added in 1.1.0
public Builder(@NonNull String id, @NonNull String name)

Creates a media route descriptor builder.

Parameters
@NonNull String id

The unique id of the route.

@NonNull String name

The user-visible name of the route.

Public methods

addControlFilter

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder addControlFilter(@NonNull IntentFilter filter)

Adds a media control intent filter for the route.

addControlFilters

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder addControlFilters(@NonNull Collection<IntentFilter> filters)

Adds a list of media control intent filters for the route.

build

Added in 1.1.0
public @NonNull MediaRouteDescriptor build()

Builds the media route descriptor.

clearControlFilters

Added in 1.4.0
public @NonNull MediaRouteDescriptor.Builder clearControlFilters()

Clears media control intent filters for the route.

setCanDisconnect

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setCanDisconnect(boolean canDisconnect)

Sets whether the route can be disconnected without stopping playback.

setConnecting

Added in 1.1.0
Deprecated in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setConnecting(boolean connecting)

Sets whether the route is in the process of connecting and is not yet ready for use.

setConnectionState

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setConnectionState(int connectionState)

Sets the route's connection state.

Parameters
int connectionState

The connection state of the route: CONNECTION_STATE_DISCONNECTED, CONNECTION_STATE_CONNECTING, or CONNECTION_STATE_CONNECTED.

setDeduplicationIds

Added in 1.6.0
public @NonNull MediaRouteDescriptor.Builder setDeduplicationIds(@NonNull Set<String> deduplicationIds)

Sets the route's deduplication ids.

Two routes are considered to come from the same receiver device if any of their respective deduplication ids match.

Parameters
@NonNull Set<String> deduplicationIds

A set of strings that uniquely identify the receiver device that backs this route.

setDescription

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setDescription(@Nullable String description)

Sets the user-visible description of the route.

The route description describes the kind of destination represented by the route. It may be a user-supplied string, a model number or brand of device.

setDeviceType

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setDeviceType(int deviceType)

Sets the route's receiver device type.

Parameters
int deviceType

The type of the receiver device.

setEnabled

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setEnabled(boolean enabled)

Sets whether the route is enabled.

Disabled routes represent routes that a route provider knows about, such as paired Wifi Display receivers, but that are not currently available for use.

setExtras

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setExtras(@Nullable Bundle extras)

Sets a bundle of extras for this route descriptor. The extras will be ignored by the media router but they may be used by applications.

setIconUri

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setIconUri(@NonNull Uri iconUri)

Sets the URI of the icon representing this route.

This icon will be used in picker UIs if available.

The URI must be one of the following formats:

setId

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setId(@NonNull String id)

Sets the unique id of the route.

The route id associated with a route descriptor functions as a stable identifier for the route and must be unique among all routes offered by the provider.

setIsDynamicGroupRoute

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setIsDynamicGroupRoute(boolean isDynamicGroupRoute)

Sets whether the route is a dynamic group route.

setName

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setName(@NonNull String name)

Sets the user-visible name of the route.

The route name identifies the destination represented by the route. It may be a user-supplied name, an alias, or device serial number.

setPlaybackStream

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setPlaybackStream(int playbackStream)

Sets the route's playback stream.

setPlaybackType

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setPlaybackType(int playbackType)

Sets the route's playback type.

Parameters
int playbackType

The playback type of the route: PLAYBACK_TYPE_LOCAL or PLAYBACK_TYPE_REMOTE.

setPresentationDisplayId

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setPresentationDisplayId(int presentationDisplayId)

Sets the route's presentation display id, or -1 if none.

setSettingsActivity

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setSettingsActivity(@Nullable IntentSender is)

Sets an intent sender for launching the settings activity for this route.

setVisibilityPublic

Added in 1.6.0
public @NonNull MediaRouteDescriptor.Builder setVisibilityPublic()

Sets the visibility of this route to public.

By default, unless you call setVisibilityRestricted, the new route will be public.

Public routes are visible to any application with a matching feature.

Calls to this method override previous calls to setVisibilityPublic and setVisibilityRestricted.

setVisibilityRestricted

Added in 1.6.0
public @NonNull MediaRouteDescriptor.Builder setVisibilityRestricted(@NonNull Set<String> allowedPackages)

Sets the visibility of this route to restricted.

Routes with restricted visibility are only visible to its publisher application and applications whose package name is included in the provided allowedPackages set with a matching feature.

Calls to this method override previous calls to setVisibilityPublic and setVisibilityRestricted.

Parameters
@NonNull Set<String> allowedPackages

set of package names which are allowed to see this route.

setVolume

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setVolume(int volume)

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

setVolumeHandling

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setVolumeHandling(int volumeHandling)

Sets the route's volume handling.

Parameters
int volumeHandling

how volume is handled on the route: PLAYBACK_VOLUME_FIXED or PLAYBACK_VOLUME_VARIABLE.

setVolumeMax

Added in 1.1.0
public @NonNull MediaRouteDescriptor.Builder setVolumeMax(int volumeMax)

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