MediaRouteActionProvider  |  API reference  |  Android Developers


public class MediaRouteActionProvider
extends ActionProvider



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(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.

Summary

Public constructors

MediaRouteActionProvider(Context context)

Public methods

boolean isVisible()

If overridesItemVisibility() returns true, the return value of this method will help determine the visibility of the MenuItem this ActionProvider is bound to.

View onCreateActionView()

This method is deprecated. use onCreateActionView(MenuItem)

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 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.

Inherited methods

From class android.view.ActionProvider

boolean hasSubMenu()

Determines if this ActionProvider has a submenu associated with it.

boolean isVisible()

If overridesItemVisibility() returns true, the return value of this method will help determine the visibility of the MenuItem this ActionProvider is bound to.

abstract View onCreateActionView()

This method was deprecated in API level 16. use onCreateActionView(MenuItem)

View onCreateActionView(MenuItem forItem)

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

boolean onPerformDefaultAction()

Performs an optional default action.

void onPrepareSubMenu(SubMenu subMenu)

Called to prepare an associated submenu for the menu item backed by this ActionProvider.

boolean overridesItemVisibility()

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.

void refreshVisibility()

If this ActionProvider is associated with an item in a menu, refresh the visibility of the item based on overridesItemVisibility() and isVisible().

void setVisibilityListener(ActionProvider.VisibilityListener listener)

Set a listener to be notified when this ActionProvider's overridden visibility changes.

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(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 wait(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 wait()

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

Public constructors

MediaRouteActionProvider

public MediaRouteActionProvider (Context context)
Parameters
context Context

Public methods

isVisible

public boolean isVisible ()

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.

Returns
boolean true if the MenuItem this ActionProvider is bound to is visible, false if it is invisible. The default implementation returns true.

onCreateActionView

public View onCreateActionView ()

This method is deprecated.
use onCreateActionView(MenuItem)

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

This method has been deprecated in favor of 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.

Returns
View A new action view.
This value cannot be null.

onCreateActionView

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 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
item MenuItem: MenuItem to create the action view for.
This value cannot be null.
Returns
View the new action view.
This value cannot be null.

overridesItemVisibility

public boolean overridesItemVisibility ()

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.

Returns
boolean true if this ActionProvider overrides the visibility of the MenuItem it is bound to, false otherwise. The default implementation returns false.

setExtendedSettingsClickListener

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

setRouteTypes

public void setRouteTypes (int types)

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.