Table of Contents

Class AndroidInterop

Interface for the native Android plugin.

public static class AndroidInterop
Inheritance
object
AndroidInterop

Methods

CreateInstance(Callbacks)

Gets an instance of the native interface.

public static AndroidJavaObject CreateInstance(AndroidInterop.Callbacks callbacks)

Parameters

callbacks AndroidInterop.Callbacks

Returns

AndroidJavaObject

A new instance of the native interface.

Remarks

This method should generally be called only once during the application's lifetime, as the native object is supposed to act like a singleton. If you create a new instance of the native object while another one is active, all unfulfilled callbacks meant for the existing instance will be forwarded to the new instance's callbacks instead.

The returned AndroidJavaObject should be disposed when no longer needed.

Exceptions

PlatformNotSupportedException

Thrown if this method is called on a runtime other than Android.

GetFileURI(AndroidJavaObject, string, string)

Creates a shareable android.net.Uri from a filepath under the given FileProvider authority's scope.

public static AndroidJavaObject? GetFileURI(AndroidJavaObject native, string path, string authority)

Parameters

native AndroidJavaObject

The native plugin instance.

path string

The filepath.

authority string

The FileProvider authority which path is under.

Returns

AndroidJavaObject?

A shareable android.net.Uri object if successful; null otherwise.

Remarks

The returned AndroidJavaObject should be disposed when no longer needed.

Exceptions

PlatformNotSupportedException

Thrown if this method is called on a runtime other than Android.

ShareText(AndroidJavaObject, int, string, string?)

Shares text data using ChooserActivity.

public static bool ShareText(AndroidJavaObject native, int id, string text, string? title)

Parameters

native AndroidJavaObject

The native plugin instance.

id int

The ID of this event, to be returned in OnTargetChosen.

text string

The text to share.

title string

Optional title for the sharesheet.

Returns

bool

true if the activity was started; false otherwise.

Exceptions

PlatformNotSupportedException

Thrown if this method is called on a runtime other than Android.

ShareURI(AndroidJavaObject, int, AndroidJavaObject, string, string?, string?)

Shares data sourced from a URI using ChooserActivity.

public static bool ShareURI(AndroidJavaObject native, int id, AndroidJavaObject uri, string type, string? text, string? title)

Parameters

native AndroidJavaObject

The native plugin instance.

id int

The ID of this event, to be returned in OnTargetChosen.

uri AndroidJavaObject

The android.net.Uri object to share.

type string

The MIME type of the content being shared through the uri.

text string

Optional additional text to share.

title string

Optional title for the sharesheet.

Returns

bool

true if the activity was started; false otherwise.

Exceptions

PlatformNotSupportedException

Thrown if this method is called on a runtime other than Android.

ShareURIs(AndroidJavaObject, int, AndroidJavaObject[], string, string?, string?)

Shares multipart data sourced from URIs using ChooserActivity.

public static bool ShareURIs(AndroidJavaObject native, int id, AndroidJavaObject[] uris, string type, string? text, string? title)

Parameters

native AndroidJavaObject

The native plugin instance.

id int

The ID of this event, to be returned in OnTargetChosen.

uris AndroidJavaObject[]

The array of android.net.Uri objects to share.

type string

The MIME type of the contents being shared through the uris.

text string

Optional additional text to share.

title string

Optional title for the sharesheet.

Returns

bool

true if the activity was started; false otherwise.

Exceptions

PlatformNotSupportedException

Thrown if this method is called on a runtime other than Android.