Android Guides | Samples

Android.Widget.ShareActionProvider Class

This is a provider for a share action.

See Also: ShareActionProvider


[Android.Runtime.Register("android/widget/ShareActionProvider", DoNotGenerateAcw=true)]
public class ShareActionProvider : ActionProvider


This is a provider for a share action. It is responsible for creating views that enable data sharing and also to show a sub menu with sharing activities if the hosting item is placed on the overflow menu.

java Example

 // In Activity#onCreateOptionsMenu
 public boolean onCreateOptionsMenu(Menu menu) {
     // Get the menu item.
     MenuItem menuItem = menu.findItem(;
     // Get the provider and hold onto it to set/change the share intent.
     mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
     // Set history different from the default before getting the action
     // view since a call to MenuItem.getActionView() calls
     // onCreateActionView() which uses the backing file name. Omit this
     // line if using the default share history file is desired.
     . . .

 // Somewhere in the application.
 public void doShare(Intent shareIntent) {
     // When you want to share set the share intent.

Here is how to use the action provider with custom backing file in a IMenuItem:

Note: While the sample snippet demonstrates how to use this provider in the context of a menu item, the use of the provider is not limited to menu items.

See Also

[Android Documentation]


Namespace: Android.Widget
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions:
Since: Added in API level 14

The members of Android.Widget.ShareActionProvider are listed below.

See Also: ActionProvider

Public Constructors

Creates a new instance.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

DefaultShareHistoryFileNameString. The default name for storing share history.

Protected Properties

ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

OnCreateActionView() : View
Factory method called by the Android framework to create new action views.
Sets a listener to be notified when a share target has been selected.
Sets the file name of a file for persisting the share history which history will be used for ordering share targets.
Sets an intent with information about the share action.

Public Events