Added in API level 11

ClipDescription

open class ClipDescription : Parcelable
kotlin.Any
   ↳ android.content.ClipDescription

Meta-data describing the contents of a ClipData. Provides enough information to know if you can handle the ClipData, but not the data itself.

Summary

Constants
static Int

Value returned by getConfidenceScore(java.lang.String) if text classification has been completed.

static Int

Value returned by getConfidenceScore(java.lang.String) if text classification has not been completed on the associated clip.

static Int

Value returned by getConfidenceScore(java.lang.String) if text classification was not and will not be performed on the associated clip.

static String

Indicates that a ClipData's source is a remote device.

static String

Indicates that a ClipData contains potentially sensitive information, such as a password or credit card number.

static String

The MIME type for a clip holding HTML text.

static String

The MIME type for a clip holding an Intent.

static String

The MIME type for a clip holding plain text.

static String

The MIME type for a clip holding one or more URIs.

static String

The MIME type for data whose type is otherwise unknown.

Inherited constants
Public constructors
ClipDescription(label: CharSequence!, mimeTypes: Array<String!>!)

Create a new clip.

Create a copy of a ClipDescription.

Public methods
open static Boolean
compareMimeTypes(concreteType: String!, desiredType: String!)

Helper to compare two MIME types, where one may be a pattern.

open Int

open Array<String!>!
filterMimeTypes(mimeType: String!)

Filter the clip description MIME types by the given MIME type.

open Int

Returns CLASSIFICATION_COMPLETE if text classification has been performed on the associated ClipData.

open Float

Returns a score indicating confidence that an instance of the given entity is present in the first item of the clip data, if that item is plain text and text classification has been performed.

open PersistableBundle!

Retrieve extended data from the clip description.

open CharSequence!

Return the label for this clip.

open String!
getMimeType(index: Int)

Return one of the possible clip MIME types.

open Int

Return the number of MIME types the clip is available in.

open Long

Return the timestamp at which the associated ClipData is copied to global clipboard in the System#currentTimeMillis() time base.

open Boolean
hasMimeType(mimeType: String!)

Check whether the clip description contains the given MIME type.

open Boolean

Returns true if the first item of the associated ClipData contains styled text, i.

open Unit

Add extended data to the clip description.

open String

open Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<ClipDescription!>

Constants

CLASSIFICATION_COMPLETE

Added in API level 31
static val CLASSIFICATION_COMPLETE: Int

Value returned by getConfidenceScore(java.lang.String) if text classification has been completed.

Value: 3

CLASSIFICATION_NOT_COMPLETE

Added in API level 31
static val CLASSIFICATION_NOT_COMPLETE: Int

Value returned by getConfidenceScore(java.lang.String) if text classification has not been completed on the associated clip. This will be always be the case if the clip has not been copied to clipboard, or if there is no associated clip.

Value: 1

CLASSIFICATION_NOT_PERFORMED

Added in API level 31
static val CLASSIFICATION_NOT_PERFORMED: Int

Value returned by getConfidenceScore(java.lang.String) if text classification was not and will not be performed on the associated clip. This may be the case if the clip does not contain text in its first item, or if the text is too long.

Value: 2

EXTRA_IS_REMOTE_DEVICE

Added in API level 34
static val EXTRA_IS_REMOTE_DEVICE: String

Indicates that a ClipData's source is a remote device.

Type: boolean

This extra can be used to indicate that a ClipData comes from a separate device rather than being local. It is a rendering hint that can be used to take different behavior based on the source device of copied data.

Value: "android.content.extra.IS_REMOTE_DEVICE"

EXTRA_IS_SENSITIVE

Added in API level 33
static val EXTRA_IS_SENSITIVE: String

Indicates that a ClipData contains potentially sensitive information, such as a password or credit card number.

Type: boolean

This extra can be used to indicate that a ClipData contains sensitive information that should be redacted or hidden from view until a user takes explicit action to reveal it (e.g., by pasting).

Adding this extra does not change clipboard behavior or add additional security to the ClipData. Its purpose is essentially a rendering hint from the source application, asking that the data within be obfuscated or redacted, unless the user has taken action to make it visible.

Value: "android.content.extra.IS_SENSITIVE"

MIMETYPE_TEXT_HTML

Added in API level 16
static val MIMETYPE_TEXT_HTML: String

The MIME type for a clip holding HTML text.

Value: "text/html"

MIMETYPE_TEXT_INTENT

Added in API level 11
static val MIMETYPE_TEXT_INTENT: String

The MIME type for a clip holding an Intent.

Value: "text/vnd.android.intent"

MIMETYPE_TEXT_PLAIN

Added in API level 11
static val MIMETYPE_TEXT_PLAIN: String

The MIME type for a clip holding plain text.

Value: "text/plain"

MIMETYPE_TEXT_URILIST

Added in API level 11
static val MIMETYPE_TEXT_URILIST: String

The MIME type for a clip holding one or more URIs. This should be used for URIs that are meaningful to a user (such as an http: URI). It should not be used for a content: URI that references some other piece of data; in that case the MIME type should be the type of the referenced data.

Value: "text/uri-list"

MIMETYPE_UNKNOWN

Added in API level 30
static val MIMETYPE_UNKNOWN: String

The MIME type for data whose type is otherwise unknown.

Per RFC 2046, the "application" media type is to be used for discrete data which do not fit in any of the other categories, and the "octet-stream" subtype is used to indicate that a body contains arbitrary binary data.

Value: "application/octet-stream"

Public constructors

ClipDescription

Added in API level 11
ClipDescription(
    label: CharSequence!,
    mimeTypes: Array<String!>!)

Create a new clip.

Parameters
label CharSequence!: Label to show to the user describing this clip.
mimeTypes Array<String!>!: An array of MIME types this data is available as.

ClipDescription

Added in API level 11
ClipDescription(o: ClipDescription!)

Create a copy of a ClipDescription.

Public methods

compareMimeTypes

Added in API level 11
open static fun compareMimeTypes(
    concreteType: String!,
    desiredType: String!
): Boolean

Helper to compare two MIME types, where one may be a pattern.

Parameters
concreteType String!: A fully-specified MIME type.
desiredType String!: A desired MIME type that may be a pattern such as */*.
Return
Boolean Returns true if the two MIME types match.

describeContents

Added in API level 11
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

filterMimeTypes

Added in API level 11
open fun filterMimeTypes(mimeType: String!): Array<String!>!

Filter the clip description MIME types by the given MIME type. Returns all MIME types in the clip that match the given MIME type.

Parameters
mimeType String!: The desired MIME type. May be a pattern.
Return
Array<String!>! Returns an array of all matching MIME types. If there are no matching MIME types, null is returned.

getClassificationStatus

Added in API level 31
open fun getClassificationStatus(): Int

Returns CLASSIFICATION_COMPLETE if text classification has been performed on the associated ClipData. If this is the case then getConfidenceScore may be used to retrieve information about entities within the text. Otherwise, returns CLASSIFICATION_NOT_COMPLETE if classification has not yet returned results, or CLASSIFICATION_NOT_PERFORMED if classification was not attempted (e.g. because the text was too long).

Return
Int Value is android.content.ClipDescription#CLASSIFICATION_NOT_COMPLETE, android.content.ClipDescription#CLASSIFICATION_NOT_PERFORMED, or android.content.ClipDescription#CLASSIFICATION_COMPLETE

getConfidenceScore

Added in API level 31
open fun getConfidenceScore(entity: String): Float

Returns a score indicating confidence that an instance of the given entity is present in the first item of the clip data, if that item is plain text and text classification has been performed. The value ranges from 0 (low confidence) to 1 (high confidence). 0 indicates that the entity was not found in the classified text.

Entities should be as defined in the TextClassifier class, such as TextClassifier#TYPE_ADDRESS, TextClassifier#TYPE_URL, or TextClassifier#TYPE_EMAIL.

If the result is positive for any entity, the full classification result as a TextLinks object may be obtained using the ClipData.Item#getTextLinks() method.

Parameters
entity String: This value cannot be null. Value is android.view.textclassifier.TextClassifier#TYPE_UNKNOWN, android.view.textclassifier.TextClassifier#TYPE_OTHER, android.view.textclassifier.TextClassifier#TYPE_EMAIL, android.view.textclassifier.TextClassifier#TYPE_PHONE, android.view.textclassifier.TextClassifier#TYPE_ADDRESS, android.view.textclassifier.TextClassifier#TYPE_URL, android.view.textclassifier.TextClassifier#TYPE_DATE, android.view.textclassifier.TextClassifier#TYPE_DATE_TIME, android.view.textclassifier.TextClassifier#TYPE_FLIGHT_NUMBER, android.view.textclassifier.TextClassifier.TYPE_DICTIONARY, or android.view.textclassifier.TextClassifier.TYPE_OTP_CODE
Return
Float Value is between 0.0 and 1.0 inclusive
Exceptions
java.lang.IllegalStateException if getClassificationStatus() is not CLASSIFICATION_COMPLETE

getExtras

Added in API level 24
open fun getExtras(): PersistableBundle!

Retrieve extended data from the clip description.

Return
PersistableBundle! the bundle containing extended data previously set with setExtras(android.os.PersistableBundle), or null if no extras have been set.

getLabel

Added in API level 11
open fun getLabel(): CharSequence!

Return the label for this clip.

getMimeType

Added in API level 11
open fun getMimeType(index: Int): String!

Return one of the possible clip MIME types.

getMimeTypeCount

Added in API level 11
open fun getMimeTypeCount(): Int

Return the number of MIME types the clip is available in.

getTimestamp

Added in API level 26
open fun getTimestamp(): Long

Return the timestamp at which the associated ClipData is copied to global clipboard in the System#currentTimeMillis() time base.

Return
Long timestamp at which the associated ClipData is copied to global clipboard or 0 if it is not copied to clipboard.

hasMimeType

Added in API level 11
open fun hasMimeType(mimeType: String!): Boolean

Check whether the clip description contains the given MIME type.

Parameters
mimeType String!: The desired MIME type. May be a pattern.
Return
Boolean Returns true if one of the MIME types in the clip description matches the desired MIME type, else false.

isStyledText

Added in API level 31
open fun isStyledText(): Boolean

Returns true if the first item of the associated ClipData contains styled text, i.e. if it contains spans such as CharacterStyle, , or . Returns false if it does not, or if there is no associated clip data.

setExtras

Added in API level 24
open fun setExtras(extras: PersistableBundle!): Unit

Add extended data to the clip description.

See Also

toString

Added in API level 11
open fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 11
open fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 11
static val CREATOR: Parcelable.Creator<ClipDescription!>