public class MediaRouteActionProvider extends ActionProvider
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(int)
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.
ActionProvider.SubUiVisibilityListener, ActionProvider.VisibilityListener
Constructor and Description |
---|
MediaRouteActionProvider(Context context) |
Modifier and Type | Method and Description |
---|---|
boolean |
isVisible()
If
ActionProvider.overridesItemVisibility() returns true, the return value of this method
will help determine the visibility of the MenuItem this ActionProvider is bound to. |
View |
onCreateActionView()
Factory method called by the Android framework to create new action views.
|
View |
onCreateActionView(MenuItem item)
Factory method called by the Android framework to create new action views.
|
boolean |
onPerformDefaultAction()
Performs an optional default action.
|
boolean |
overridesItemVisibility()
The result of this method determines whether or not
ActionProvider.isVisible() will be used
by the MenuItem this ActionProvider is bound to help determine its visibility. |
void |
setExtendedSettingsClickListener(View.OnClickListener listener) |
void |
setRouteTypes(int types)
Sets the types of routes that will be shown in the media route chooser dialog
launched by this button.
|
hasSubMenu, onPrepareSubMenu, refreshVisibility, reset, setSubUiVisibilityListener, setVisibilityListener, subUiVisibilityChanged
public MediaRouteActionProvider(Context context)
public void setRouteTypes(int types)
types
- The route types to match.public void setExtendedSettingsClickListener(View.OnClickListener listener)
public View onCreateActionView()
ActionProvider
This method has been deprecated in favor of ActionProvider.onCreateActionView(MenuItem)
.
Newer apps that wish to support platform versions prior to API 16 should also
implement this method to return a valid action view.
onCreateActionView
in class ActionProvider
public View onCreateActionView(MenuItem item)
ActionProvider
If your ActionProvider implementation overrides the deprecated no-argument overload
ActionProvider.onCreateActionView()
, overriding this method for devices running API 16 or later
is recommended but optional. The default implementation calls ActionProvider.onCreateActionView()
for compatibility with applications written for older platform versions.
onCreateActionView
in class ActionProvider
item
- MenuItem to create the action view forpublic boolean onPerformDefaultAction()
ActionProvider
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:
MenuItem.OnMenuItemClickListener.onMenuItemClick
.
Activity.onOptionsItemSelected(MenuItem)
Fragment.onOptionsItemSelected(MenuItem)
Intent
set via
MenuItem.setIntent(android.content.Intent)
The default implementation does not perform any action and returns false.
onPerformDefaultAction
in class ActionProvider
public boolean overridesItemVisibility()
ActionProvider
ActionProvider.isVisible()
will be used
by the MenuItem
this ActionProvider is bound to help determine its visibility.overridesItemVisibility
in class ActionProvider
ActionProvider.isVisible()
public boolean isVisible()
ActionProvider
ActionProvider.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.
isVisible
in class ActionProvider