BrowserActionsIntent

Added in 1.2.0
Deprecated in 1.2.0

public class 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 types

public final class BrowserActionsIntent.Builder

Builder class for opening a Browser Actions context menu.

Constants

static final String
ACTION_BROWSER_ACTIONS_OPEN = "androidx.browser.browseractions.browser_action_open"

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

static final String
EXTRA_APP_ID = "androidx.browser.browseractions.APP_ID"

Extra that specifies PendingIntent indicating which Application sends the .

static final String
EXTRA_MENU_ITEMS = "androidx.browser.browseractions.extra.MENU_ITEMS"

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

static final String
EXTRA_SELECTED_ACTION_PENDING_INTENT = "androidx.browser.browseractions.extra.SELECTED_ACTION_PENDING_INTENT"

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

static final String
EXTRA_TYPE = "androidx.browser.browseractions.extra.TYPE"

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

static final int
static final int
static final int
static final int
static final int
static final int
static final String
KEY_ACTION = "androidx.browser.browseractions.ACTION"

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

static final String
KEY_ICON_ID = "androidx.browser.browseractions.ICON_ID"

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

static final String
KEY_TITLE = "androidx.browser.browseractions.TITLE"

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

static final int

The maximum allowed number of custom items.

static final int
static final int
static final int
static final int
static final int
static final int

Public methods

static @Nullable String

This method is deprecated.

This return value of this method cannot be trusted, it is kept around for compatibility.

@NonNull Intent

Gets the Intent of BrowserActionsIntent.

static @Nullable String

Get the package name of the creator application.

static void
launchIntent(@NonNull Context context, @NonNull Intent intent)

Launch an Intent to open a Browser Actions menu.

static void

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

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

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

static @NonNull List<BrowserActionItem>

Gets custom item list for browser action menu.

Constants

ACTION_BROWSER_ACTIONS_OPEN

Added in 1.2.0
Deprecated in 1.2.0
public static final String ACTION_BROWSER_ACTIONS_OPEN = "androidx.browser.browseractions.browser_action_open"

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

EXTRA_APP_ID

Added in 1.2.0
Deprecated in 1.2.0
public static final String EXTRA_APP_ID = "androidx.browser.browseractions.APP_ID"

Extra that specifies PendingIntent indicating which Application sends the .

Note: The PendingIntent is self-reported and untrusted, sending application can modify it to use PendingIntent from other apps. This would return the package name from the app who creates the PendintIntent.

EXTRA_MENU_ITEMS

Added in 1.2.0
Deprecated in 1.2.0
public static final String EXTRA_MENU_ITEMS = "androidx.browser.browseractions.extra.MENU_ITEMS"

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

EXTRA_SELECTED_ACTION_PENDING_INTENT

Added in 1.2.0
Deprecated in 1.2.0
public static final String EXTRA_SELECTED_ACTION_PENDING_INTENT = "androidx.browser.browseractions.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.

EXTRA_TYPE

Added in 1.2.0
Deprecated in 1.2.0
public static final String EXTRA_TYPE = "androidx.browser.browseractions.extra.TYPE"

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

ITEM_COPY

Added in 1.2.0
Deprecated in 1.2.0
public static final int ITEM_COPY = 3

ITEM_DOWNLOAD

Added in 1.2.0
Deprecated in 1.2.0
public static final int ITEM_DOWNLOAD = 2

ITEM_INVALID_ITEM

Added in 1.2.0
Deprecated in 1.2.0
public static final int ITEM_INVALID_ITEM = -1

ITEM_OPEN_IN_INCOGNITO

Added in 1.2.0
Deprecated in 1.2.0
public static final int ITEM_OPEN_IN_INCOGNITO = 1

ITEM_OPEN_IN_NEW_TAB

Added in 1.2.0
Deprecated in 1.2.0
public static final int ITEM_OPEN_IN_NEW_TAB = 0

ITEM_SHARE

Added in 1.2.0
Deprecated in 1.2.0
public static final int ITEM_SHARE = 4

KEY_ACTION

Added in 1.2.0
Deprecated in 1.2.0
public static final String KEY_ACTION = "androidx.browser.browseractions.ACTION"

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

KEY_ICON_ID

Added in 1.2.0
Deprecated in 1.2.0
public static final String KEY_ICON_ID = "androidx.browser.browseractions.ICON_ID"

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

KEY_TITLE

Added in 1.2.0
Deprecated in 1.2.0
public static final String KEY_TITLE = "androidx.browser.browseractions.TITLE"

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

MAX_CUSTOM_ITEMS

Added in 1.2.0
Deprecated in 1.2.0
public static final int MAX_CUSTOM_ITEMS = 5

The maximum allowed number of custom items.

URL_TYPE_AUDIO

Added in 1.2.0
Deprecated in 1.2.0
public static final int URL_TYPE_AUDIO = 3

URL_TYPE_FILE

Added in 1.2.0
Deprecated in 1.2.0
public static final int URL_TYPE_FILE = 4

URL_TYPE_IMAGE

Added in 1.2.0
Deprecated in 1.2.0
public static final int URL_TYPE_IMAGE = 1

URL_TYPE_NONE

Added in 1.2.0
Deprecated in 1.2.0
public static final int URL_TYPE_NONE = 0

URL_TYPE_PLUGIN

Added in 1.2.0
Deprecated in 1.2.0
public static final int URL_TYPE_PLUGIN = 5

URL_TYPE_VIDEO

Added in 1.2.0
Deprecated in 1.2.0
public static final int URL_TYPE_VIDEO = 2

Public methods

getCreatorPackageName

Added in 1.2.0
Deprecated in 1.2.0
public static @Nullable String getCreatorPackageName(@NonNull Intent intent)

getIntent

Added in 1.2.0
Deprecated in 1.2.0
public @NonNull Intent getIntent()

Gets the Intent of BrowserActionsIntent.

Returns
@NonNull Intent

the Intent of BrowserActionsIntent.

getUntrustedCreatorPackageName

Added in 1.2.0
Deprecated in 1.2.0
public static @Nullable String getUntrustedCreatorPackageName(@NonNull Intent intent)

Get the package name of the creator application.

Note: This is self-reported and could be untrusted. Intent sender can modify it to return the package name from a different application.

Parameters
@NonNull Intent intent

The BrowserActionsIntent.

Returns
@Nullable String

The creator package name.

launchIntent

Added in 1.2.0
Deprecated in 1.2.0
public static void launchIntent(@NonNull Context context, @NonNull 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
@NonNull Context context

The context requesting for a Browser Actions menu.

@NonNull Intent intent

The Intent holds the setting for Browser Actions menu.

openBrowserAction

Added in 1.2.0
Deprecated in 1.2.0
public static void openBrowserAction(@NonNull Context context, @NonNull Uri uri)

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

Parameters
@NonNull Context context

The context requesting for a Browser Actions menu.

@NonNull Uri uri

The url for Browser Actions menu.

openBrowserAction

Added in 1.2.0
Deprecated in 1.2.0
public static void openBrowserAction(
    @NonNull Context context,
    @NonNull Uri uri,
    int type,
    @NonNull ArrayList<BrowserActionItem> items,
    @NonNull PendingIntent pendingIntent
)

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

Parameters
@NonNull Context context

The context requesting for a Browser Actions menu.

@NonNull Uri uri

The url for Browser Actions menu.

int type

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

@NonNull ArrayList<BrowserActionItem> items

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

@NonNull PendingIntent pendingIntent

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

parseBrowserActionItems

Added in 1.2.0
Deprecated in 1.2.0
public static @NonNull List<BrowserActionItemparseBrowserActionItems(@NonNull ArrayList<Bundle> bundles)

Gets custom item list for browser action menu.

Parameters
@NonNull ArrayList<Bundle> bundles

Data for custom items from BrowserActionsIntent.