# MediaRouteSelector

Artifact: [androidx.mediarouter:mediarouter](https://developer.android.com/jetpack/androidx/releases/mediarouter) [View Source](https://cs.android.com/search?q=file:androidx/mediarouter/media/MediaRouteSelector.java+class:androidx.mediarouter.media.MediaRouteSelector) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

*** ** * ** ***


```
public final class MediaRouteSelector
```

<br />

*** ** * ** ***

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

This object is immutable once created using a `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector.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 https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector.Builder` Builder for `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector`. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#EMPTY()` An empty media route selector that will not match any routes. |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#asBundle()()` Converts this object to a bundle for serialization. |
| `boolean` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#contains(androidx.mediarouter.media.MediaRouteSelector)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector selector)` Returns true if this selector contains all of the capabilities described by the specified selector. |
| `boolean` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html o)` |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#fromBundle(android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/os/Bundle.html bundle)` Creates an instance from a bundle. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#getControlCategories()()` Gets the list of `https://developer.android.com/reference/androidx/mediarouter/media/MediaControlIntent` in the selector. |
| `boolean` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#hasControlCategory(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html category)` Returns true if the selector contains the specified category. |
| `int` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#isEmpty()()` Returns true if the selector does not specify any capabilities. |
| `boolean` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#isValid()()` Returns true if the selector has all of the required fields. |
| `boolean` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#matchesControlFilters(java.util.List<android.content.IntentFilter>)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/android/content/IntentFilter.html> filters)` Returns true if the selector matches at least one of the specified control filters. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector#toString()()` |

## Constants

### EMPTY

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#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](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
public @NonNull Bundle asBundle()
```

Converts this object to a bundle for serialization.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html` | The contents of the object represented as a bundle. |

### contains

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/mediarouter/media/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](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
public static @Nullable MediaRouteSelector fromBundle(@Nullable Bundle bundle)
```

Creates an instance from a bundle.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/os/Bundle.html bundle` | The bundle, or null if none. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/mediarouter/media/MediaRouteSelector` | The new instance, or null if the bundle was null. |

### getControlCategories

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
public @NonNull List<String> getControlCategories()
```

Gets the list of `https://developer.android.com/reference/androidx/mediarouter/media/MediaControlIntent` in the selector.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | The list of categories. |

### hasControlCategory

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
public boolean hasControlCategory(@Nullable String category)
```

Returns true if the selector contains the specified category.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html category` | The category to check. |

| Returns |
|---|---|
| `boolean` | `true` if the category is present. |

### hashCode

```
public int hashCode()
```

### isEmpty

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
public boolean isEmpty()
```

Returns true if the selector does not specify any capabilities.

### isValid

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
public boolean isValid()
```

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

### matchesControlFilters

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/android/content/IntentFilter.html> filters` | The list of control filters to consider. |

| Returns |
|---|---|
| `boolean` | True if a match is found. |

### toString

```
public @NonNull String toString()
```