InputContentInfoCompat

Added in 1.1.0

public final class InputContentInfoCompat


Helper for accessing features in InputContentInfo introduced after API level 13 in a backwards compatible fashion.

Summary

Public constructors

InputContentInfoCompat(
    @NonNull Uri contentUri,
    @NonNull ClipDescription description,
    @Nullable Uri linkUri
)

Constructs InputContentInfoCompat.

Public methods

@NonNull Uri
@NonNull ClipDescription
@Nullable Uri
void

Releases a temporary read-only access permission for content URI associated with this object.

void

Requests a temporary read-only access permission for content URI associated with this object.

@Nullable Object

Gets the underlying framework android.view.inputmethod.InputContentInfo object.

static @Nullable InputContentInfoCompat
wrap(@Nullable Object inputContentInfo)

Creates an instance from a framework android.view.inputmethod.InputContentInfo object.

Public constructors

InputContentInfoCompat

Added in 1.1.0
public InputContentInfoCompat(
    @NonNull Uri contentUri,
    @NonNull ClipDescription description,
    @Nullable Uri linkUri
)

Constructs InputContentInfoCompat.

Parameters
@NonNull Uri contentUri

content URI to be exported from the input method. This cannot be null.

@NonNull ClipDescription description

a ClipDescription object that contains the metadata of contentUri such as MIME type(s). This object cannot be null. Also getLabel should be describing the content specified by contentUri for accessibility reasons.

@Nullable Uri linkUri

an optional http or https URI. The editor author may provide a way to navigate the user to the specified web page if this is not null.

Public methods

getContentUri

Added in 1.1.0
public @NonNull Uri getContentUri()
Returns
@NonNull Uri

content URI with which the content can be obtained.

getDescription

Added in 1.1.0
public @NonNull ClipDescription getDescription()
Returns
@NonNull ClipDescription

ClipDescription object that contains the metadata of #getContentUri() such as MIME type(s). getLabel can be used for accessibility purpose.

getLinkUri

Added in 1.1.0
public @Nullable Uri getLinkUri()
Returns
@Nullable Uri

an optional http or https URI that is related to this content.

releasePermission

Added in 1.1.0
public void releasePermission()

Releases a temporary read-only access permission for content URI associated with this object.

Does nothing if the temporary permission is not granted.

requestPermission

Added in 1.1.0
public void requestPermission()

Requests a temporary read-only access permission for content URI associated with this object.

The lifecycle of the permission granted here is tied to this object instance. If the permission is not released explicitly via releasePermission, it will be released automatically when there are no more references to this object.

Does nothing if the temporary permission is already granted.

unwrap

Added in 1.1.0
public @Nullable Object unwrap()

Gets the underlying framework android.view.inputmethod.InputContentInfo object.

This method always returns null on API <= 24.

Returns
@Nullable Object

an equivalent android.view.inputmethod.InputContentInfo object, or null if not supported.

wrap

Added in 1.1.0
public static @Nullable InputContentInfoCompat wrap(@Nullable Object inputContentInfo)

Creates an instance from a framework android.view.inputmethod.InputContentInfo object.

This method always returns null on API <= 24.

Parameters
@Nullable Object inputContentInfo

an android.view.inputmethod.InputContentInfo object, or null if none.

Returns
@Nullable InputContentInfoCompat

an equivalent InputContentInfoCompat object, or null if not supported.