BrowserActionsIntent
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.BuilderBuilder 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 |
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 |
ITEM_COPY = 3 |
static final int |
ITEM_DOWNLOAD = 2 |
static final int |
ITEM_INVALID_ITEM = -1 |
static final int |
|
static final int |
|
static final int |
ITEM_SHARE = 4 |
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 |
MAX_CUSTOM_ITEMS = 5The maximum allowed number of custom items. |
static final int |
URL_TYPE_AUDIO = 3 |
static final int |
URL_TYPE_FILE = 4 |
static final int |
URL_TYPE_IMAGE = 1 |
static final int |
URL_TYPE_NONE = 0 |
static final int |
URL_TYPE_PLUGIN = 5 |
static final int |
URL_TYPE_VIDEO = 2 |
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 |
static @Nullable String |
Get the package name of the creator application. |
static void |
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 |
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
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.
public static final String EXTRA_APP_ID = "androidx.browser.browseractions.APP_ID"
Extra that specifies PendingIntent indicating which Application sends the BrowserActionsIntent.
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.
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.
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.
public static final String EXTRA_TYPE = "androidx.browser.browseractions.extra.TYPE"
Extra that specifies the type of url for the Browser Actions menu.
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.
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.
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.
Public methods
public @NonNull IntentgetIntent()
Gets the Intent of BrowserActionsIntent.
| Returns | |
|---|---|
@NonNull Intent |
the Intent of |
public static @Nullable StringgetUntrustedCreatorPackageName(@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 |
public static voidlaunchIntent(@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.
public static voidopenBrowserAction(@NonNull Context context, @NonNull Uri uri)
Construct a BrowserActionsIntent with default settings and launch it to open a Browser Actions menu.
public static voidopenBrowserAction(
@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. |
public static @NonNull List<BrowserActionItem>parseBrowserActionItems(@NonNull ArrayList<Bundle> bundles)
Gets custom item list for browser action menu.
| Parameters | |
|---|---|
@NonNull ArrayList<Bundle> bundles |
Data for custom items from |
| Returns | |
|---|---|
@NonNull List<BrowserActionItem> |
List of |