ShareTarget
class 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 types |
|---|
|
Defines a form field for sharing files. |
class ShareTarget.ParamsContains parameter names to be used for the data being shared. |
Constants |
|
|---|---|
const String! |
ENCODING_TYPE_MULTIPART = "multipart/form-data"An encoding type to be used with POST requests (see |
const String! |
ENCODING_TYPE_URL_ENCODED = "application/x-www-form-urlencoded"An encoding type to be used with POST requests (see |
const String! |
KEY_ACTION = "androidx.browser.trusted.sharing.KEY_ACTION"Bundle key for |
const String! |
KEY_ENCTYPE = "androidx.browser.trusted.sharing.KEY_ENCTYPE"Bundle key for |
const String! |
KEY_METHOD = "androidx.browser.trusted.sharing.KEY_METHOD"Bundle key for |
const String! |
KEY_PARAMS = "androidx.browser.trusted.sharing.KEY_PARAMS"Bundle key for |
const String! |
METHOD_GET = "GET"See |
const String! |
METHOD_POST = "POST"See |
Public constructors |
|---|
ShareTarget(Creates a |
Public functions |
|
|---|---|
java-static ShareTarget? |
fromBundle(bundle: Bundle)Unpacks the object from a |
Bundle |
toBundle()Packs the object into a |
Public properties |
|
|---|---|
String |
URL of the Web Share Target. |
String? |
Specifies how the shared data should be encoded in the body of a POST request. |
String? |
HTTP request method for the Web Share Target. |
ShareTarget.Params |
Contains the parameter names, see |
Constants
ENCODING_TYPE_MULTIPART
const val ENCODING_TYPE_MULTIPART = "multipart/form-data": String!
An encoding type to be used with POST requests (see encodingType) corresponding to multipart/form-data of the HTTP POST standard [1].
ENCODING_TYPE_URL_ENCODED
const val ENCODING_TYPE_URL_ENCODED = "application/x-www-form-urlencoded": String!
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
KEY_ACTION
const val KEY_ACTION = "androidx.browser.trusted.sharing.KEY_ACTION": String!
Bundle key for action.
KEY_ENCTYPE
const val KEY_ENCTYPE = "androidx.browser.trusted.sharing.KEY_ENCTYPE": String!
Bundle key for encodingType.
KEY_METHOD
const val KEY_METHOD = "androidx.browser.trusted.sharing.KEY_METHOD": String!
Bundle key for method.
KEY_PARAMS
const val KEY_PARAMS = "androidx.browser.trusted.sharing.KEY_PARAMS": String!
Bundle key for params.
Public constructors
ShareTarget
ShareTarget(
action: String,
method: String?,
encodingType: String?,
params: ShareTarget.Params
)
Creates a ShareTarget with the given parameters.
| Parameters | |
|---|---|
action: String |
The |
method: String? |
The |
encodingType: String? |
The |
params: ShareTarget.Params |
The |
Public functions
fromBundle
java-static fun fromBundle(bundle: Bundle): ShareTarget?
Unpacks the object from a Bundle.
Public properties
action
val action: String
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
val encodingType: String?
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
val method: String?
HTTP request method for the Web Share Target. Must be METHOD_GET or METHOD_POST. Default is METHOD_GET.