Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/app/MediaRouteActionProvider#pubctors) \| [Methods](https://developer.android.com/reference/android/app/MediaRouteActionProvider#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/MediaRouteActionProvider#inhmethods)

# MediaRouteActionProvider

*** ** * ** ***

` public class MediaRouteActionProvider `   
` ` ` extends https://developer.android.com/reference/android/view/ActionProvider ` ` `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.view.ActionProvider](https://developer.android.com/reference/android/view/ActionProvider) ||
|   | ↳ | android.app.MediaRouteActionProvider |

<br />

*** ** * ** ***

The media route action provider displays a `https://developer.android.com/reference/android/app/MediaRouteButton` in the application's `https://developer.android.com/reference/android/app/ActionBar` to allow the user to select routes and to control the currently selected route.

The application must specify the kinds of routes that the user should be allowed to select by specifying the route types with the `https://developer.android.com/reference/android/app/MediaRouteActionProvider#setRouteTypes(int)` method.

Refer to `https://developer.android.com/reference/android/app/MediaRouteButton` for a description of the button that will appear in the action bar menu. Note that instead of disabling the button when no routes are available, the action provider will instead make the menu item invisible. In this way, the button will only be visible when it is possible for the user to discover and select a matching route.

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/MediaRouteActionProvider#MediaRouteActionProvider(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/android/app/MediaRouteActionProvider#isVisible()() ` If `https://developer.android.com/reference/android/view/ActionProvider#overridesItemVisibility()` returns true, the return value of this method will help determine the visibility of the `https://developer.android.com/reference/android/view/MenuItem` this ActionProvider is bound to. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/app/MediaRouteActionProvider#onCreateActionView()() ` *This method is deprecated. use `https://developer.android.com/reference/android/view/ActionProvider#onCreateActionView(android.view.MenuItem)`* |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/app/MediaRouteActionProvider#onCreateActionView(android.view.MenuItem)(https://developer.android.com/reference/android/view/MenuItem item) ` Factory method called by the Android framework to create new action views. |
| ` boolean` | ` https://developer.android.com/reference/android/app/MediaRouteActionProvider#onPerformDefaultAction()() ` Performs an optional default action. |
| ` boolean` | ` https://developer.android.com/reference/android/app/MediaRouteActionProvider#overridesItemVisibility()() ` The result of this method determines whether or not `https://developer.android.com/reference/android/view/ActionProvider#isVisible()` will be used by the `https://developer.android.com/reference/android/view/MenuItem` this ActionProvider is bound to help determine its visibility. |
| ` void` | ` https://developer.android.com/reference/android/app/MediaRouteActionProvider#setExtendedSettingsClickListener(android.view.View.OnClickListener)(https://developer.android.com/reference/android/view/View.OnClickListener listener) ` |
| ` void` | ` https://developer.android.com/reference/android/app/MediaRouteActionProvider#setRouteTypes(int)(int types) ` Sets the types of routes that will be shown in the media route chooser dialog launched by this button. |

### Inherited methods

From class ` https://developer.android.com/reference/android/view/ActionProvider ` ` boolean` ` https://developer.android.com/reference/android/view/ActionProvider#hasSubMenu()() `

Determines if this ActionProvider has a submenu associated with it.
` boolean` ` https://developer.android.com/reference/android/view/ActionProvider#isVisible()() `

If `https://developer.android.com/reference/android/view/ActionProvider#overridesItemVisibility()` returns true, the return value of this method will help determine the visibility of the `https://developer.android.com/reference/android/view/MenuItem` this ActionProvider is bound to.
` abstract https://developer.android.com/reference/android/view/View` ` https://developer.android.com/reference/android/view/ActionProvider#onCreateActionView()() `

*This method was deprecated in API level 16. use `https://developer.android.com/reference/android/view/ActionProvider#onCreateActionView(android.view.MenuItem)`*
` https://developer.android.com/reference/android/view/View` ` https://developer.android.com/reference/android/view/ActionProvider#onCreateActionView(android.view.MenuItem)(https://developer.android.com/reference/android/view/MenuItem forItem) `

Factory method called by the Android framework to create new action views.
` boolean` ` https://developer.android.com/reference/android/view/ActionProvider#onPerformDefaultAction()() `

Performs an optional default action.
` void` ` https://developer.android.com/reference/android/view/ActionProvider#onPrepareSubMenu(android.view.SubMenu)(https://developer.android.com/reference/android/view/SubMenu subMenu) `

Called to prepare an associated submenu for the menu item backed by this ActionProvider.
` boolean` ` https://developer.android.com/reference/android/view/ActionProvider#overridesItemVisibility()() `

The result of this method determines whether or not `https://developer.android.com/reference/android/view/ActionProvider#isVisible()` will be used by the `https://developer.android.com/reference/android/view/MenuItem` this ActionProvider is bound to help determine its visibility.
` void` ` https://developer.android.com/reference/android/view/ActionProvider#refreshVisibility()() `

If this ActionProvider is associated with an item in a menu, refresh the visibility of the item based on `https://developer.android.com/reference/android/view/ActionProvider#overridesItemVisibility()` and `https://developer.android.com/reference/android/view/ActionProvider#isVisible()`.
` void` ` https://developer.android.com/reference/android/view/ActionProvider#setVisibilityListener(android.view.ActionProvider.VisibilityListener)(https://developer.android.com/reference/android/view/ActionProvider.VisibilityListener listener) `

Set a listener to be notified when this ActionProvider's overridden visibility changes.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### MediaRouteActionProvider

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MediaRouteActionProvider (Context context)
```

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |

## Public methods

### isVisible

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isVisible ()
```

If `https://developer.android.com/reference/android/view/ActionProvider#overridesItemVisibility()` returns true, the return value of this method will help determine the visibility of the `https://developer.android.com/reference/android/view/MenuItem` this ActionProvider is bound to.

If the MenuItem's visibility is explicitly set to false by the application, the MenuItem will not be shown, even if this method returns true.

<br />

<br />

| Returns ||
|---|---|
| `boolean` | true if the MenuItem this ActionProvider is bound to is visible, false if it is invisible. The default implementation returns true. <br /> |

### onCreateActionView

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View onCreateActionView ()
```

<br />

**This method is deprecated.**   

use `https://developer.android.com/reference/android/view/ActionProvider#onCreateActionView(android.view.MenuItem)`

Factory method called by the Android framework to create new action views.

This method has been deprecated in favor of `https://developer.android.com/reference/android/view/ActionProvider#onCreateActionView(android.view.MenuItem)`. Newer apps that wish to support platform versions prior to API 16 should also implement this method to return a valid action view.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | A new action view. This value cannot be `null`. <br /> |

### onCreateActionView

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View onCreateActionView (MenuItem item)
```

Factory method called by the Android framework to create new action views. This method returns a new action view for the given MenuItem.

If your ActionProvider implementation overrides the deprecated no-argument overload `https://developer.android.com/reference/android/view/ActionProvider#onCreateActionView()`, overriding this method for devices running API 16 or later is recommended but optional. The default implementation calls `https://developer.android.com/reference/android/view/ActionProvider#onCreateActionView()` for compatibility with applications written for older platform versions.

<br />

<br />

| Parameters ||
|---|---|
| `item` | `MenuItem`: MenuItem to create the action view for. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | the new action view. This value cannot be `null`. <br /> |

### onPerformDefaultAction

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onPerformDefaultAction ()
```

Performs an optional default action.

For the case of an action provider placed in a menu item not shown as an action this method is invoked if previous callbacks for processing menu selection has handled the event.

A menu item selection is processed in the following order:

- Receiving a call to `https://developer.android.com/reference/android/view/MenuItem.OnMenuItemClickListener#onMenuItemClick(android.view.MenuItem)`.
- Receiving a call to `https://developer.android.com/reference/android/app/Activity#onOptionsItemSelected(android.view.MenuItem)`
- Receiving a call to `https://developer.android.com/reference/android/app/Fragment#onOptionsItemSelected(android.view.MenuItem)`
- Launching the `https://developer.android.com/reference/android/content/Intent` set via `https://developer.android.com/reference/android/view/MenuItem#setIntent(android.content.Intent)`
- Invoking this method.

<br />

The default implementation does not perform any action and returns false.

<br />

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### overridesItemVisibility

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean overridesItemVisibility ()
```

The result of this method determines whether or not `https://developer.android.com/reference/android/view/ActionProvider#isVisible()` will be used by the `https://developer.android.com/reference/android/view/MenuItem` this ActionProvider is bound to help determine its visibility.

<br />

| Returns ||
|---|---|
| `boolean` | true if this ActionProvider overrides the visibility of the MenuItem it is bound to, false otherwise. The default implementation returns false. <br /> |

### setExtendedSettingsClickListener

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setExtendedSettingsClickListener (View.OnClickListener listener)
```

<br />

<br />

| Parameters ||
|---|---|
| `listener` | `View.OnClickListener` <br /> |

### setRouteTypes

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setRouteTypes (int types)
```

Sets the types of routes that will be shown in the media route chooser dialog launched by this button.

<br />

| Parameters ||
|---|---|
| `types` | `int`: The route types to match. <br /> |