lightbulb_outline Please take our October 2018 developer survey. Start survey
added in version 1.0.0
belongs to Maven artifact androidx.browser:browser:1.0.0

BrowserActionsIntent

public class BrowserActionsIntent
extends Object

java.lang.Object
   ↳ androidx.browser.browseractions.BrowserActionsIntent


Class holding the Intent and start bundle for a Browser Actions Activity.

Note: The constants below are public for the browser implementation's benefit. You are strongly encouraged to use BrowserActionsIntent.Builder.

Summary

Nested classes

class BrowserActionsIntent.Builder

Builder class for opening a Browser Actions context menu. 

Constants

String ACTION_BROWSER_ACTIONS_OPEN

Indicates that the user explicitly opted out of Browser Actions in the calling application.

String EXTRA_APP_ID

Extra that specifies PendingIntent indicating which Application sends the BrowserActionsIntent.

String EXTRA_MENU_ITEMS

Extra that specifies List used for adding custom items to the Browser Actions menu.

String EXTRA_SELECTED_ACTION_PENDING_INTENT

Extra that specifies the PendingIntent to be launched when a browser specified menu item is selected.

String EXTRA_TYPE

Extra that specifies the type of url for the Browser Actions menu.

int ITEM_COPY

int ITEM_DOWNLOAD

int ITEM_INVALID_ITEM

int ITEM_OPEN_IN_INCOGNITO

int ITEM_OPEN_IN_NEW_TAB

int ITEM_SHARE

String KEY_ACTION

Extra PendingIntent to be launched when a custom item is selected in the Browser Actions menu.

String KEY_ICON_ID

Extra resource id that specifies the icon of a custom item shown in the Browser Actions menu.

String KEY_TITLE

Extra string that specifies the title of a custom item shown in the Browser Actions menu.

int MAX_CUSTOM_ITEMS

The maximum allowed number of custom items.

int URL_TYPE_AUDIO

int URL_TYPE_FILE

int URL_TYPE_IMAGE

int URL_TYPE_NONE

int URL_TYPE_PLUGIN

int URL_TYPE_VIDEO

Public methods

static String getCreatorPackageName(Intent intent)

Get the package name of the creator application.

Intent getIntent()

Gets the Intent of BrowserActionsIntent.

static void launchIntent(Context context, Intent intent)

Launch an Intent to open a Browser Actions menu.

static void openBrowserAction(Context context, Uri uri, int type, ArrayList<BrowserActionItem> items, PendingIntent pendingIntent)

Construct a BrowserActionsIntent with custom settings and launch it to open a Browser Actions menu.

static void openBrowserAction(Context context, Uri uri)

Construct a BrowserActionsIntent with default settings and launch it to open a Browser Actions menu.

static List<BrowserActionItem> parseBrowserActionItems(ArrayList<Bundle> bundles)

Gets custom item list for browser action menu.

Inherited methods

Constants

ACTION_BROWSER_ACTIONS_OPEN

added in version 1.0.0
public static final String ACTION_BROWSER_ACTIONS_OPEN

Indicates that the user explicitly opted out of Browser Actions in the calling application.

Constant Value: "androidx.browser.browseractions.browser_action_open"

EXTRA_APP_ID

added in version 1.0.0
public static final String EXTRA_APP_ID

Extra that specifies PendingIntent indicating which Application sends the BrowserActionsIntent.

Constant Value: "androidx.browser.browseractions.APP_ID"

EXTRA_MENU_ITEMS

added in version 1.0.0
public static final String EXTRA_MENU_ITEMS

Extra that specifies List used for adding custom items to the Browser Actions menu.

Constant Value: "androidx.browser.browseractions.extra.MENU_ITEMS"

EXTRA_SELECTED_ACTION_PENDING_INTENT

added in version 1.0.0
public static final String EXTRA_SELECTED_ACTION_PENDING_INTENT

Extra that specifies the PendingIntent to be launched when a browser specified menu item is selected. The id of the chosen item will be notified through the data of its Intent.

Constant Value: "androidx.browser.browseractions.extra.SELECTED_ACTION_PENDING_INTENT"

EXTRA_TYPE

added in version 1.0.0
public static final String EXTRA_TYPE

Extra that specifies the type of url for the Browser Actions menu.

Constant Value: "androidx.browser.browseractions.extra.TYPE"

ITEM_COPY

added in version 1.0.0
public static final int ITEM_COPY

Constant Value: 3 (0x00000003)

ITEM_DOWNLOAD

added in version 1.0.0
public static final int ITEM_DOWNLOAD

Constant Value: 2 (0x00000002)

ITEM_INVALID_ITEM

added in version 1.0.0
public static final int ITEM_INVALID_ITEM

Constant Value: -1 (0xffffffff)

ITEM_OPEN_IN_INCOGNITO

added in version 1.0.0
public static final int ITEM_OPEN_IN_INCOGNITO

Constant Value: 1 (0x00000001)

ITEM_OPEN_IN_NEW_TAB

added in version 1.0.0
public static final int ITEM_OPEN_IN_NEW_TAB

Constant Value: 0 (0x00000000)

ITEM_SHARE

added in version 1.0.0
public static final int ITEM_SHARE

Constant Value: 4 (0x00000004)

KEY_ACTION

added in version 1.0.0
public static final String KEY_ACTION

Extra PendingIntent to be launched when a custom item is selected in the Browser Actions menu.

Constant Value: "androidx.browser.browseractions.ACTION"

KEY_ICON_ID

added in version 1.0.0
public static final String KEY_ICON_ID

Extra resource id that specifies the icon of a custom item shown in the Browser Actions menu.

Constant Value: "androidx.browser.browseractions.ICON_ID"

KEY_TITLE

added in version 1.0.0
public static final String KEY_TITLE

Extra string that specifies the title of a custom item shown in the Browser Actions menu.

Constant Value: "androidx.browser.browseractions.TITLE"

MAX_CUSTOM_ITEMS

added in version 1.0.0
public static final int MAX_CUSTOM_ITEMS

The maximum allowed number of custom items.

Constant Value: 5 (0x00000005)

URL_TYPE_AUDIO

added in version 1.0.0
public static final int URL_TYPE_AUDIO

Constant Value: 3 (0x00000003)

URL_TYPE_FILE

added in version 1.0.0
public static final int URL_TYPE_FILE

Constant Value: 4 (0x00000004)

URL_TYPE_IMAGE

added in version 1.0.0
public static final int URL_TYPE_IMAGE

Constant Value: 1 (0x00000001)

URL_TYPE_NONE

added in version 1.0.0
public static final int URL_TYPE_NONE

Constant Value: 0 (0x00000000)

URL_TYPE_PLUGIN

added in version 1.0.0
public static final int URL_TYPE_PLUGIN

Constant Value: 5 (0x00000005)

URL_TYPE_VIDEO

added in version 1.0.0
public static final int URL_TYPE_VIDEO

Constant Value: 2 (0x00000002)

Public methods

getCreatorPackageName

added in version 1.0.0
public static String getCreatorPackageName (Intent intent)

Get the package name of the creator application.

Parameters
intent Intent: The BrowserActionsIntent.

Returns
String The creator package name.

getIntent

added in version 1.0.0
public Intent getIntent ()

Gets the Intent of BrowserActionsIntent.

Returns
Intent the Intent of BrowserActionsIntent.

launchIntent

added in version 1.0.0
public static void launchIntent (Context context, 
                Intent intent)

Launch an Intent to open a Browser Actions menu. It first checks if any Browser Actions provider is available to create the menu. If the default Browser supports Browser Actions, menu will be opened by the default Browser, otherwise show a intent picker. If not provider, a Browser Actions menu is opened locally from support library.

Parameters
context Context: The context requesting for a Browser Actions menu.

intent Intent: The Intent holds the setting for Browser Actions menu.

openBrowserAction

added in version 1.0.0
public static void openBrowserAction (Context context, 
                Uri uri, 
                int type, 
                ArrayList<BrowserActionItem> items, 
                PendingIntent pendingIntent)

Construct a BrowserActionsIntent with custom settings and launch it to open a Browser Actions menu.

Parameters
context Context: The context requesting for a Browser Actions menu.

uri Uri: The url for Browser Actions menu.

type int: The type of the url for context menu to be opened.

items ArrayList: List of custom items to be added to Browser Actions menu.

pendingIntent PendingIntent: The PendingIntent to be launched when a browser specified menu item is selected.

openBrowserAction

added in version 1.0.0
public static void openBrowserAction (Context context, 
                Uri uri)

Construct a BrowserActionsIntent with default settings and launch it to open a Browser Actions menu.

Parameters
context Context: The context requesting for a Browser Actions menu.

uri Uri: The url for Browser Actions menu.

parseBrowserActionItems

added in version 1.0.0
public static List<BrowserActionItem> parseBrowserActionItems (ArrayList<Bundle> bundles)

Gets custom item list for browser action menu.

Parameters
bundles ArrayList: Data for custom items from BrowserActionsIntent.

Returns
List<BrowserActionItem> List of BrowserActionItem