MediaRouteActionProvider
open class MediaRouteActionProvider : ActionProvider
| kotlin.Any | ||
| ↳ | android.view.ActionProvider | |
| ↳ | android.app.MediaRouteActionProvider | |
The media route action provider displays a media route button in the application's 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 setRouteTypes method.
Refer to 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.
Summary
| Public constructors | |
|---|---|
MediaRouteActionProvider(context: Context!) |
|
| Public methods | |
|---|---|
| open Boolean |
If |
| open View |
Factory method called by the Android framework to create new action views. |
| open View |
onCreateActionView(item: MenuItem)Factory method called by the Android framework to create new action views. |
| open Boolean |
Performs an optional default action. |
| open Boolean |
The result of this method determines whether or not |
| open Unit |
setExtendedSettingsClickListener(listener: View.OnClickListener!) |
| open Unit |
setRouteTypes(types: Int)Sets the types of routes that will be shown in the media route chooser dialog launched by this button. |
| Inherited functions | |
|---|---|
Public constructors
Public methods
isVisible
open fun isVisible(): Boolean
If overridesItemVisibility() returns true, the return value of this method will help determine the visibility of the 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.
| Return | |
|---|---|
Boolean |
true if the MenuItem this ActionProvider is bound to is visible, false if it is invisible. The default implementation returns true. |
onCreateActionView
open fun onCreateActionView(): View
Factory method called by the Android framework to create new action views.
This method has been deprecated in favor of 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.
| Return | |
|---|---|
View |
A new action view. This value cannot be null. |
onCreateActionView
open fun onCreateActionView(item: MenuItem): View
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 onCreateActionView(), overriding this method for devices running API 16 or later is recommended but optional. The default implementation calls onCreateActionView() for compatibility with applications written for older platform versions.
| Parameters | |
|---|---|
forItem |
MenuItem to create the action view for. This value cannot be null. |
| Return | |
|---|---|
View |
the new action view. This value cannot be null. |
onPerformDefaultAction
open fun onPerformDefaultAction(): Boolean
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
MenuItem.OnMenuItemClickListener.onMenuItemClick. - Receiving a call to
Activity.onOptionsItemSelected(MenuItem) - Receiving a call to
Fragment.onOptionsItemSelected(MenuItem) - Launching the
android.content.Intentset viaMenuItem.setIntent(android.content.Intent) - Invoking this method.
The default implementation does not perform any action and returns false.
overridesItemVisibility
open fun overridesItemVisibility(): Boolean
The result of this method determines whether or not isVisible() will be used by the MenuItem this ActionProvider is bound to help determine its visibility.
| Return | |
|---|---|
Boolean |
true if this ActionProvider overrides the visibility of the MenuItem it is bound to, false otherwise. The default implementation returns false. |
setExtendedSettingsClickListener
open fun setExtendedSettingsClickListener(listener: View.OnClickListener!): Unit
setRouteTypes
open fun setRouteTypes(types: Int): Unit
Sets the types of routes that will be shown in the media route chooser dialog launched by this button.
| Parameters | |
|---|---|
types |
Int: The route types to match. |