# SelectionInfo

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

*** ** * ** ***


```
public final class SelectionInfo
```

<br />

*** ** * ** ***

Information about a route selection.

This information is available in callbacks like `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter.Callback#onRouteSelected(androidx.mediarouter.media.MediaRouter,androidx.mediarouter.media.MediaRouter.RouteInfo,androidx.mediarouter.media.MediaRouter.RouteInfo,androidx.mediarouter.media.SelectionInfo)` for apps to know the reason and the source of the event. For example, you can check if the route was selected by the app (`https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_APP()`) (this includes in-app UI interactions) or via the system output switcher (`https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_SYSTEM()`). Similarly, apps can know if the previous route was unselected because it was disconnected (`https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter#UNSELECT_REASON_DISCONNECTED()`) or simply stopped (`https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter#UNSELECT_REASON_STOPPED()`).

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#getSelectionSource()` |   |
| `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#getUnselectReason()` |   |

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo.Builder` Builder for `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo`. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_APP() = 1` The route was selected because the application explicitly requested it (for example, by calling `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter#selectRoute(androidx.mediarouter.media.MediaRouter.RouteInfo)`). |
| `static final int` | `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_PROVIDER() = 3` The route was selected because the provider changed the route (for example, fallback to default route when the active route is disconnected by the provider). |
| `static final int` | `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_SYSTEM() = 2` The route was selected because of a system/platform event (for example, System Output Switcher selection). |
| `static final int` | `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_UNKNOWN() = 0` Passed when the reason the route was selected is unknown. |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#getSelectionSource()()` Returns the source of the route selection. |
| `int` | `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#getUnselectReason()()` Returns the unselect reason of the previously selected route. |

## Constants

### SELECTION_SOURCE_APP

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

```
public static final int SELECTION_SOURCE_APP = 1
```

The route was selected because the application explicitly requested it (for example, by calling `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter#selectRoute(androidx.mediarouter.media.MediaRouter.RouteInfo)`).

### SELECTION_SOURCE_PROVIDER

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

```
public static final int SELECTION_SOURCE_PROVIDER = 3
```

The route was selected because the provider changed the route (for example, fallback to default route when the active route is disconnected by the provider).

### SELECTION_SOURCE_SYSTEM

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

```
public static final int SELECTION_SOURCE_SYSTEM = 2
```

The route was selected because of a system/platform event (for example, System Output Switcher selection).

### SELECTION_SOURCE_UNKNOWN

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

```
public static final int SELECTION_SOURCE_UNKNOWN = 0
```

Passed when the reason the route was selected is unknown.

## Public methods

### getSelectionSource

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

```
public int getSelectionSource()
```

Returns the source of the route selection.

| Returns |
|---|---|
| `int` | The selection source. One of `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_UNKNOWN()`, `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_APP()`, `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_SYSTEM()`, or `https://developer.android.com/reference/androidx/mediarouter/media/SelectionInfo#SELECTION_SOURCE_PROVIDER()`. |

### getUnselectReason

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

```
public int getUnselectReason()
```

Returns the unselect reason of the previously selected route.

| Returns |
|---|---|
| `int` | The unselect reason. One of `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter#UNSELECT_REASON_UNKNOWN()`, `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter#UNSELECT_REASON_DISCONNECTED()`, `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter#UNSELECT_REASON_STOPPED()`, or `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter#UNSELECT_REASON_ROUTE_CHANGED()`. |