ShareTarget

class ShareTarget
kotlin.Any
   ↳ 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

Defines a form field for sharing files.

Contains parameter names to be used for the data being shared.

Constants

static String

An encoding type to be used with POST requests (see encodingType) corresponding to multipart/form-data of the HTTP POST standard [1].

static 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].

static String

Bundle key for action.

static String

Bundle key for encodingType.

static String

Bundle key for method.

static String

Bundle key for params.

static String

See method.

static String

See method.

Public constructors

<init>(@NonNull action: String, @Nullable method: String?, @Nullable encodingType: String?, @NonNull params: ShareTarget.Params)

Creates a ShareTarget with the given parameters.

Public methods

static ShareTarget?
fromBundle(@NonNull bundle: Bundle)

Unpacks the object from a Bundle.

Bundle

Packs the object into a Bundle.

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 Params.

Constants

ENCODING_TYPE_MULTIPART

static val ENCODING_TYPE_MULTIPART: String

An encoding type to be used with POST requests (see encodingType) corresponding to multipart/form-data of the HTTP POST standard [1].

Value: "multipart/form-data"

ENCODING_TYPE_URL_ENCODED

static val ENCODING_TYPE_URL_ENCODED: 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

Value: "application/x-www-form-urlencoded"

KEY_ACTION

static val KEY_ACTION: String

Bundle key for action.

Value: "androidx.browser.trusted.sharing.KEY_ACTION"

KEY_ENCTYPE

static val KEY_ENCTYPE: String

Bundle key for encodingType.

Value: "androidx.browser.trusted.sharing.KEY_ENCTYPE"

KEY_METHOD

static val KEY_METHOD: String

Bundle key for method.

Value: "androidx.browser.trusted.sharing.KEY_METHOD"

KEY_PARAMS

static val KEY_PARAMS: String

Bundle key for params.

Value: "androidx.browser.trusted.sharing.KEY_PARAMS"

METHOD_GET

static val METHOD_GET: String

See method.

Value: "GET"

METHOD_POST

static val METHOD_POST: String

See method.

Value: "POST"

Public constructors

<init>

ShareTarget(@NonNull action: String, @Nullable method: String?, @Nullable encodingType: String?, @NonNull params: ShareTarget.Params)

Creates a ShareTarget with the given parameters.

Parameters
action String: The action.
method String: The method.
encodingType String: The encodingType.
params String: The params.

Public methods

fromBundle

@Nullable static fun fromBundle(@NonNull bundle: Bundle): ShareTarget?

Unpacks the object from a Bundle.

toBundle

@NonNull fun toBundle(): Bundle

Packs the object into a Bundle.

Properties

action

@NonNull 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

@Nullable 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

@Nullable val method: String?

HTTP request method for the Web Share Target. Must be METHOD_GET or METHOD_POST. Default is METHOD_GET.

params

@NonNull val params: ShareTarget.Params

Contains the parameter names, see Params.