public abstract class ActionProvider

Known direct subclasses

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.


Provides a share action, which is suitable for an activity's app bar.

This class is a mediator for accomplishing a given task, for example sharing a file. It is responsible for creating a view that performs an action that accomplishes the task. This class also implements other functions such a performing a default action.

An ActionProvider can be optionally specified for a android.view.MenuItem and in such a case it will be responsible for creating the action view that appears in the as a substitute for the menu item when the item is displayed as an action item. Also the provider is responsible for performing a default action if a menu item placed on the overflow menu of the ActionBar is selected and none of the menu item callbacks has handled the selection. For this case the provider can also optionally provide a sub-menu for accomplishing the task at hand.

There are two ways for using an action provider for creating and handling of action views:

  • Setting the action provider on a android.view.MenuItem directly by calling setActionProvider.
  • Declaring the action provider in the menu XML resource. For example:
      <item android:id="@+id/my_menu_item"
        android:actionProviderClass="" />
### Creating a custom action provider

To create a custom action provider, extend ActionProvider and implement its callback methods as necessary. In particular, implement the following methods:


Nested types


Listens to changes in visibility as reported by refreshVisibility.

Public constructors

Creates a new instance.

Public methods

@NonNull Context

Gets the context associated with this action provider.


Determines if this ActionProvider has a submenu associated with it.


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

abstract @NonNull View

Factory method for creating new action views.

@NonNull View