ShareTarget
public
final
class
ShareTarget
extends Object
| java.lang.Object | |
| ↳ | androidx.browser.trusted.sharing.ShareTarget |
Describes a Web Share Target associated with a Trusted Web Activity. The structure of a ShareTarget object follows the specification [1] of the "share_target" object within web manifest json, with the following exceptions: - The "action" field specifies the full URL of the Share Target, and not only the path. - There is no "url" field in the "params" object, since urls are not supplied separately from text in Android's ACTION_SEND and ACTION_SEND_MULTIPLE intents. [1] https://wicg.github.io/web-share-target/level-2/
Summary
Nested classes | |
|---|---|
class |
ShareTarget.FileFormField
Defines a form field for sharing files. |
class |
ShareTarget.Params
Contains parameter names to be used for the data being shared. |
Constants | |
|---|---|
String |
ENCODING_TYPE_MULTIPART
An encoding type to be used with POST requests (see |
String |
ENCODING_TYPE_URL_ENCODED
An encoding type to be used with POST requests (see |
String |
KEY_ACTION
Bundle key for |
String |
KEY_ENCTYPE
Bundle key for |
String |
KEY_METHOD
Bundle key for |
String |
KEY_PARAMS
Bundle key for |
String |
METHOD_GET
See |
String |
METHOD_POST
See |
Fields | |
|---|---|
public
final
String |
action
URL of the Web Share Target. |
public
final
String |
encodingType
Specifies how the shared data should be encoded in the body of a POST request. |
public
final
String |
method
HTTP request method for the Web Share Target. |
public
final
ShareTarget.Params |
params
Contains the parameter names, see |
Public constructors | |
|---|---|
ShareTarget(String action, String method, String encodingType, ShareTarget.Params params)
Creates a |
|
Public methods | |
|---|---|
static
ShareTarget
|
fromBundle(Bundle bundle)
Unpacks the object from a |
Bundle
|
toBundle()
Packs the object into a |
Inherited methods | |
|---|---|
Constants
ENCODING_TYPE_MULTIPART
public static final String ENCODING_TYPE_MULTIPART
An encoding type to be used with POST requests (see encodingType) corresponding to
multipart/form-data of the HTTP POST standard [1].
Constant Value: "multipart/form-data"
ENCODING_TYPE_URL_ENCODED
public static final String ENCODING_TYPE_URL_ENCODED
An encoding type to be used with POST requests (see encodingType) corresponding to
application/x-www-form-urlencoded of the HTTP POST standard [1].
[1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
Constant Value: "application/x-www-form-urlencoded"
KEY_ACTION
public static final String KEY_ACTION
Bundle key for action.
Constant Value: "androidx.browser.trusted.sharing.KEY_ACTION"
KEY_ENCTYPE
public static final String KEY_ENCTYPE
Bundle key for encodingType.
Constant Value: "androidx.browser.trusted.sharing.KEY_ENCTYPE"
KEY_METHOD
public static final String KEY_METHOD
Bundle key for method.
Constant Value: "androidx.browser.trusted.sharing.KEY_METHOD"
KEY_PARAMS
public static final String KEY_PARAMS
Bundle key for params.
Constant Value: "androidx.browser.trusted.sharing.KEY_PARAMS"
Fields
action
public final String action
URL of the Web Share Target. Must belong to an origin associated with the Trusted Web Activity. For example, assuming the origin is "https://mypwa.com", the action could be "https://mypwa.com/share.html".
encodingType
public final String encodingType
Specifies how the shared data should be encoded in the body of a POST request. Must be
ENCODING_TYPE_MULTIPART or ENCODING_TYPE_URL_ENCODED. Default is
ENCODING_TYPE_URL_ENCODED.
method
public final String method
HTTP request method for the Web Share Target. Must be METHOD_GET or
METHOD_POST. Default is METHOD_GET.
Public constructors
ShareTarget
public ShareTarget (String action,
String method,
String encodingType,
ShareTarget.Params params)
Creates a ShareTarget with the given parameters.
| Parameters | |
|---|---|
action |
String: The action. |
method |
String: The method. |
encodingType |
String: The encodingType. |
params |
ShareTarget.Params: The params.
|
Public methods
fromBundle
public static ShareTarget fromBundle (Bundle bundle)
Unpacks the object from a Bundle.
| Parameters | |
|---|---|
bundle |
Bundle |
| Returns | |
|---|---|
ShareTarget |
|
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-09-30 UTC.