MediaRouteSelector


public final class MediaRouteSelector


Describes the capabilities of routes that applications would like to discover and use.

This object is immutable once created using a Builder instance.

Example

MediaRouteSelector selector = new MediaRouteSelector.Builder()
        .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
        .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
        .build();

MediaRouter router = MediaRouter.getInstance(context);
router.addCallback(selector, callback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);

Summary

Nested types

public final class MediaRouteSelector.Builder

Builder for media route selectors.

Constants

static final MediaRouteSelector

An empty media route selector that will not match any routes.

Public methods

@NonNull Bundle

Converts this object to a bundle for serialization.

boolean

Returns true if this selector contains all of the capabilities described by the specified selector.

boolean
static @Nullable MediaRouteSelector

Creates an instance from a bundle.

@NonNull List<String>

Gets the list of media control categories in the selector.

boolean

Returns true if the selector contains the specified category.

int
boolean

Returns true if the selector does not specify any capabilities.

boolean

Returns true if the selector has all of the required fields.

boolean

Returns true if the selector matches at least one of the specified control filters.

@NonNull String

Constants

EMPTY

Added in 1.1.0
public static final MediaRouteSelector EMPTY

An empty media route selector that will not match any routes.

Public methods

asBundle

Added in 1.1.0
public @NonNull Bundle asBundle()

Converts this object to a bundle for serialization.

Returns
@NonNull Bundle

The contents of the object represented as a bundle.

contains

Added in 1.1.0
public boolean contains(@NonNull MediaRouteSelector selector)

Returns true if this selector contains all of the capabilities described by the specified selector.

Parameters
@NonNull MediaRouteSelector selector

The selector to be examined.

Returns
boolean

True if this selector contains all of the capabilities described by the specified selector.

equals

public boolean equals(Object o)

fromBundle

Added in 1.1.0
public static @Nullable MediaRouteSelector fromBundle(@Nullable Bundle bundle)

Creates an instance from a bundle.

Parameters
@Nullable Bundle bundle

The bundle, or null if none.

Returns
@Nullable MediaRouteSelector

The new instance, or null if the bundle was null.

getControlCategories

Added in 1.1.0
public @NonNull List<StringgetControlCategories()

Gets the list of media control categories in the selector.

Returns
@NonNull List<String>

The list of categories.

hasControlCategory

Added in 1.1.0
public boolean hasControlCategory(@Nullable String category)

Returns true if the selector contains the specified category.

Parameters
@Nullable String category

The category to check.

Returns
boolean

true if the category is present.

hashCode

public int hashCode()

isEmpty

Added in 1.1.0
public boolean isEmpty()

Returns true if the selector does not specify any capabilities.

isValid

Added in 1.1.0
public boolean isValid()

Returns true if the selector has all of the required fields.

matchesControlFilters

Added in 1.1.0
public boolean matchesControlFilters(@Nullable List<IntentFilter> filters)

Returns true if the selector matches at least one of the specified control filters.

Parameters
@Nullable List<IntentFilter> filters

The list of control filters to consider.

Returns
boolean

True if a match is found.

toString

public @NonNull String toString()