Added in API level 30

Builder


class Builder
kotlin.Any
   ↳ android.media.MediaRoute2Info.Builder

Builder for media route info.

Summary

Public constructors

Constructor for builder to create MediaRoute2Info with existing MediaRoute2Info instance.

Constructor for builder to create MediaRoute2Info.

Public methods
MediaRoute2Info.Builder
addFeature(feature: String)

Adds a feature for the route.

MediaRoute2Info.Builder

Adds features for the route.

MediaRoute2Info

Builds the media route info.

MediaRoute2Info.Builder

Clears the features of the route.

MediaRoute2Info.Builder

Sets the package name of the app using the route.

MediaRoute2Info.Builder
setConnectionState(connectionState: Int)

Sets the route's connection state.

MediaRoute2Info.Builder

Sets the deduplication IDs of the route.

MediaRoute2Info.Builder

Sets the user-visible description of the route.

MediaRoute2Info.Builder
setExtras(extras: Bundle?)

Sets a bundle of extras for the route.

MediaRoute2Info.Builder
setIconUri(iconUri: Uri?)

Sets the URI of the icon representing this route.

MediaRoute2Info.Builder
setSuitabilityStatus(suitabilityStatus: Int)

Sets route suitability status.

MediaRoute2Info.Builder
setType(type: Int)

Sets the route's type.

MediaRoute2Info.Builder

Sets the visibility of this route to public.

MediaRoute2Info.Builder

Sets the visibility of this route to restricted.

MediaRoute2Info.Builder
setVolume(volume: Int)

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

MediaRoute2Info.Builder
setVolumeHandling(volumeHandling: Int)

Sets the route's volume handling.

MediaRoute2Info.Builder
setVolumeMax(volumeMax: Int)

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

Public constructors

Builder

Added in API level 30
Builder(routeInfo: MediaRoute2Info)

Constructor for builder to create MediaRoute2Info with existing MediaRoute2Info instance.

Parameters
routeInfo MediaRoute2Info: the existing instance to copy data from. This value cannot be null.

Builder

Added in API level 30
Builder(
    id: String,
    name: CharSequence)

Constructor for builder to create MediaRoute2Info.

In order to ensure ID uniqueness, the ID of a route info obtained from MediaRouter2 can be different from what was set in MediaRoute2ProviderService.

Parameters
id String: The ID of the route. Must not be empty. This value cannot be null.
name CharSequence: The user-visible name of the route. This value cannot be null.

Public methods

addFeature

Added in API level 30
fun addFeature(feature: String): MediaRoute2Info.Builder

Adds a feature for the route.

Parameters
feature String: a feature that the route has. May be one of predefined features such as FEATURE_LIVE_AUDIO, FEATURE_LIVE_VIDEO or FEATURE_REMOTE_PLAYBACK or a custom feature defined by a provider. This value cannot be null.
Return
MediaRoute2Info.Builder This value cannot be null.

addFeatures

Added in API level 30
fun addFeatures(features: MutableCollection<String!>): MediaRoute2Info.Builder

Adds features for the route. A route must support at least one route type.

Parameters
features MutableCollection<String!>: features that the route has. May include predefined features such as FEATURE_LIVE_AUDIO, FEATURE_LIVE_VIDEO or FEATURE_REMOTE_PLAYBACK or custom features defined by a provider. This value cannot be null.
Return
MediaRoute2Info.Builder This value cannot be null.

build

Added in API level 30
fun build(): MediaRoute2Info

Builds the media route info.

Return
MediaRoute2Info This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if no features are added.

clearFeatures

Added in API level 30
fun clearFeatures(): MediaRoute2Info.Builder

Clears the features of the route. A route must support at least one route type.

Return
MediaRoute2Info.Builder This value cannot be null.

setClientPackageName

Added in API level 30
fun setClientPackageName(packageName: String?): MediaRoute2Info.Builder

Sets the package name of the app using the route.

Parameters
packageName String?: This value may be null.
Return
MediaRoute2Info.Builder This value cannot be null.

setDeduplicationIds

Added in API level 34
fun setDeduplicationIds(id: MutableSet<String!>): MediaRoute2Info.Builder

Sets the deduplication IDs of the route.

Parameters
id MutableSet<String!>: This value cannot be null.
Return
MediaRoute2Info.Builder This value cannot be null.

setDescription

Added in API level 30
fun setDescription(description: CharSequence?): MediaRoute2Info.Builder

Sets the user-visible description of the route.

Parameters
description CharSequence?: This value may be null.
Return
MediaRoute2Info.Builder This value cannot be null.

setExtras

Added in API level 30
fun setExtras(extras: Bundle?): MediaRoute2Info.Builder

Sets a bundle of extras for the route.

Note: The extras will not affect the result of MediaRoute2Info.equals(Object).

Parameters
extras Bundle?: This value may be null.
Return
MediaRoute2Info.Builder This value cannot be null.

setIconUri

Added in API level 30
fun setIconUri(iconUri: Uri?): MediaRoute2Info.Builder

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:

Parameters
iconUri Uri?: This value may be null.
Return
MediaRoute2Info.Builder This value cannot be null.

setType

Added in API level 34
fun setType(type: Int): MediaRoute2Info.Builder

Sets the route's type.

Parameters
type Int: Value is android.media.MediaRoute2Info#TYPE_UNKNOWN, android.media.MediaRoute2Info#TYPE_BUILTIN_SPEAKER, android.media.MediaRoute2Info#TYPE_WIRED_HEADSET, android.media.MediaRoute2Info#TYPE_WIRED_HEADPHONES, android.media.MediaRoute2Info#TYPE_BLUETOOTH_A2DP, android.media.MediaRoute2Info#TYPE_HDMI, android.media.MediaRoute2Info#TYPE_HDMI_ARC, android.media.MediaRoute2Info#TYPE_HDMI_EARC, android.media.MediaRoute2Info.TYPE_LINE_DIGITAL, android.media.MediaRoute2Info.TYPE_LINE_ANALOG, android.media.MediaRoute2Info.TYPE_AUX_LINE, android.media.MediaRoute2Info#TYPE_USB_DEVICE, android.media.MediaRoute2Info#TYPE_USB_ACCESSORY, android.media.MediaRoute2Info#TYPE_DOCK, android.media.MediaRoute2Info#TYPE_USB_HEADSET, android.media.MediaRoute2Info#TYPE_HEARING_AID, android.media.MediaRoute2Info#TYPE_BLE_HEADSET, android.media.MediaRoute2Info#TYPE_REMOTE_TV, android.media.MediaRoute2Info#TYPE_REMOTE_SPEAKER, android.media.MediaRoute2Info#TYPE_REMOTE_AUDIO_VIDEO_RECEIVER, android.media.MediaRoute2Info#TYPE_REMOTE_TABLET, android.media.MediaRoute2Info#TYPE_REMOTE_TABLET_DOCKED, android.media.MediaRoute2Info#TYPE_REMOTE_COMPUTER, android.media.MediaRoute2Info#TYPE_REMOTE_GAME_CONSOLE, android.media.MediaRoute2Info#TYPE_REMOTE_CAR, android.media.MediaRoute2Info#TYPE_REMOTE_SMARTWATCH, android.media.MediaRoute2Info#TYPE_REMOTE_SMARTPHONE, or android.media.MediaRoute2Info#TYPE_GROUP
Return
MediaRoute2Info.Builder This value cannot be null.

setVisibilityPublic

Added in API level 34
fun setVisibilityPublic(): MediaRoute2Info.Builder

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.

Return
MediaRoute2Info.Builder This value cannot be null.

setVisibilityRestricted

Added in API level 34
fun setVisibilityRestricted(allowedPackages: MutableSet<String!>): MediaRoute2Info.Builder

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
allowedPackages MutableSet<String!>: set of package names which are allowed to see this route. This value cannot be null.
Return
MediaRoute2Info.Builder This value cannot be null.

setVolume

Added in API level 30
fun setVolume(volume: Int): MediaRoute2Info.Builder

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

Return
MediaRoute2Info.Builder This value cannot be null.

setVolumeHandling

Added in API level 30
fun setVolumeHandling(volumeHandling: Int): MediaRoute2Info.Builder

Sets the route's volume handling.

Parameters
volumeHandling Int: Value is android.media.MediaRoute2Info#PLAYBACK_VOLUME_FIXED, or android.media.MediaRoute2Info#PLAYBACK_VOLUME_VARIABLE
Return
MediaRoute2Info.Builder This value cannot be null.

setVolumeMax

Added in API level 30
fun setVolumeMax(volumeMax: Int): MediaRoute2Info.Builder

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

Return
MediaRoute2Info.Builder This value cannot be null.