MediaRouteDescriptor.Builder
public final class MediaRouteDescriptor.Builder
Builder for media route descriptors.
Summary
Public constructors |
|---|
Builder(@NonNull MediaRouteDescriptor descriptor)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 |
addControlFilter(@NonNull IntentFilter filter)Adds a |
@NonNull MediaRouteDescriptor.Builder |
addControlFilters(@NonNull Collection<IntentFilter> filters)Adds a list of |
@NonNull MediaRouteDescriptor |
build()Builds the |
@NonNull MediaRouteDescriptor.Builder |
Clears |
@NonNull MediaRouteDescriptor.Builder |
setCanDisconnect(boolean canDisconnect)Sets whether the route can be disconnected without stopping playback. |
@NonNull MediaRouteDescriptor.Builder |
This method is deprecated. Use |
@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 |
setDescription(@Nullable String description)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 |
setIconUri(@NonNull Uri iconUri)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 |
setVisibilityRestricted(@NonNull Set<String> allowedPackages)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
public Builder(@NonNull MediaRouteDescriptor descriptor)
Creates a media route descriptor builder whose initial contents are copied from an existing descriptor.
Public methods
addControlFilter
public @NonNull MediaRouteDescriptor.Builder addControlFilter(@NonNull IntentFilter filter)
Adds a media control intent filter for the route.
addControlFilters
public @NonNull MediaRouteDescriptor.Builder addControlFilters(@NonNull Collection<IntentFilter> filters)
Adds a list of media control intent filters for the route.
build
public @NonNull MediaRouteDescriptor build()
Builds the media route descriptor.
clearControlFilters
public @NonNull MediaRouteDescriptor.Builder clearControlFilters()
Clears media control intent filters for the route.
setCanDisconnect
public @NonNull MediaRouteDescriptor.Builder setCanDisconnect(boolean canDisconnect)
Sets whether the route can be disconnected without stopping playback.
public @NonNull MediaRouteDescriptor.BuildersetConnecting(boolean connecting)
Sets whether the route is in the process of connecting and is not yet ready for use.
setConnectionState
public @NonNull MediaRouteDescriptor.Builder setConnectionState(int connectionState)
Sets the route's connection state.
| Parameters | |
|---|---|
int connectionState |
The connection state of the route: |
setDeduplicationIds
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.
setDescription
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
public @NonNull MediaRouteDescriptor.Builder setDeviceType(int deviceType)
Sets the route's receiver device type.
| Parameters | |
|---|---|
int deviceType |
The type of the receiver device. |
setEnabled
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
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
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:
- content (
SCHEME_CONTENT) - android.resource (
SCHEME_ANDROID_RESOURCE) - file (
SCHEME_FILE)
setId
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
public @NonNull MediaRouteDescriptor.Builder setIsDynamicGroupRoute(boolean isDynamicGroupRoute)
Sets whether the route is a dynamic group route.
| See also | |
|---|---|
isDynamicGroupRoute |
setName
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
public @NonNull MediaRouteDescriptor.Builder setPlaybackStream(int playbackStream)
Sets the route's playback stream.
setPlaybackType
public @NonNull MediaRouteDescriptor.Builder setPlaybackType(int playbackType)
Sets the route's playback type.
| Parameters | |
|---|---|
int playbackType |
The playback type of the route: |
setPresentationDisplayId
public @NonNull MediaRouteDescriptor.Builder setPresentationDisplayId(int presentationDisplayId)
Sets the route's presentation display id, or -1 if none.
setSettingsActivity
public @NonNull MediaRouteDescriptor.Builder setSettingsActivity(@Nullable IntentSender is)
Sets an intent sender for launching the settings activity for this route.
setVisibilityPublic
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
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. |
| See also | |
|---|---|
setVisibilityPublic |
setVolume
public @NonNull MediaRouteDescriptor.Builder setVolume(int volume)
Sets the route's current volume, or 0 if unknown.
setVolumeHandling
public @NonNull MediaRouteDescriptor.Builder setVolumeHandling(int volumeHandling)
Sets the route's volume handling.
| Parameters | |
|---|---|
int volumeHandling |
how volume is handled on the route: |
setVolumeMax
public @NonNull MediaRouteDescriptor.Builder setVolumeMax(int volumeMax)
Sets the route's maximum volume, or 0 if unknown.