ClipDescription
public
class
ClipDescription
extends Object
implements
Parcelable
java.lang.Object | |
↳ | 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.
Developer Guides
For more information about using the clipboard framework, read the Copy and Paste developer guide.
Summary
Constants | |
---|---|
int |
CLASSIFICATION_COMPLETE
Value returned by |
int |
CLASSIFICATION_NOT_COMPLETE
Value returned by |
int |
CLASSIFICATION_NOT_PERFORMED
Value returned by |
String |
EXTRA_IS_REMOTE_DEVICE
Indicates that a ClipData's source is a remote device. |
String |
EXTRA_IS_SENSITIVE
Indicates that a ClipData contains potentially sensitive information, such as a password or credit card number. |
String |
MIMETYPE_TEXT_HTML
The MIME type for a clip holding HTML text. |
String |
MIMETYPE_TEXT_INTENT
The MIME type for a clip holding an Intent. |
String |
MIMETYPE_TEXT_PLAIN
The MIME type for a clip holding plain text. |
String |
MIMETYPE_TEXT_URILIST
The MIME type for a clip holding one or more URIs. |
String |
MIMETYPE_UNKNOWN
The MIME type for data whose type is otherwise unknown. |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<ClipDescription> |
CREATOR
|
Public constructors | |
---|---|
ClipDescription(ClipDescription o)
Create a copy of a ClipDescription. |
|
ClipDescription(CharSequence label, String[] mimeTypes)
Create a new clip. |
Public methods | |
---|---|
static
boolean
|
compareMimeTypes(String concreteType, String desiredType)
Helper to compare two MIME types, where one may be a pattern. |
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
String[]
|
filterMimeTypes(String mimeType)
Filter the clip description MIME types by the given MIME type. |
int
|
getClassificationStatus()
Returns |
float
|
getConfidenceScore(String entity)
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. |
PersistableBundle
|
getExtras()
Retrieve extended data from the clip description. |
CharSequence
|
getLabel()
Return the label for this clip. |
String
|
getMimeType(int index)
Return one of the possible clip MIME types. |
int
|
getMimeTypeCount()
Return the number of MIME types the clip is available in. |
long
|
getTimestamp()
Return the timestamp at which the associated |
boolean
|
hasMimeType(String mimeType)
Check whether the clip description contains the given MIME type. |
boolean
|
isStyledText()
Returns true if the first item of the associated |
void
|
setExtras(PersistableBundle extras)
Add extended data to the clip description. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Constants
CLASSIFICATION_COMPLETE
public static final int CLASSIFICATION_COMPLETE
Value returned by getConfidenceScore(java.lang.String)
if text classification has been
completed.
Constant Value: 3 (0x00000003)
CLASSIFICATION_NOT_COMPLETE
public static final int CLASSIFICATION_NOT_COMPLETE
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.
Constant Value: 1 (0x00000001)
CLASSIFICATION_NOT_PERFORMED
public static final int CLASSIFICATION_NOT_PERFORMED
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.
Constant Value: 2 (0x00000002)
EXTRA_IS_REMOTE_DEVICE
public static final String EXTRA_IS_REMOTE_DEVICE
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.
Constant Value: "android.content.extra.IS_REMOTE_DEVICE"
EXTRA_IS_SENSITIVE
public static final String EXTRA_IS_SENSITIVE
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.
Constant Value: "android.content.extra.IS_SENSITIVE"
MIMETYPE_TEXT_HTML
public static final String MIMETYPE_TEXT_HTML
The MIME type for a clip holding HTML text.
Constant Value: "text/html"
MIMETYPE_TEXT_INTENT
public static final String MIMETYPE_TEXT_INTENT
The MIME type for a clip holding an Intent.
Constant Value: "text/vnd.android.intent"
MIMETYPE_TEXT_PLAIN
public static final String MIMETYPE_TEXT_PLAIN
The MIME type for a clip holding plain text.
Constant Value: "text/plain"
MIMETYPE_TEXT_URILIST
public static final String MIMETYPE_TEXT_URILIST
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.
Constant Value: "text/uri-list"
MIMETYPE_UNKNOWN
public static final String MIMETYPE_UNKNOWN
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.
Constant Value: "application/octet-stream"
Fields
Public constructors
ClipDescription
public ClipDescription (ClipDescription o)
Create a copy of a ClipDescription.
Parameters | |
---|---|
o |
ClipDescription |
ClipDescription
public ClipDescription (CharSequence label, String[] mimeTypes)
Create a new clip.
Parameters | |
---|---|
label |
CharSequence : Label to show to the user describing this clip. |
mimeTypes |
String : An array of MIME types this data is available as. |
Public methods
compareMimeTypes
public static boolean compareMimeTypes (String concreteType, String desiredType)
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 */*. |
Returns | |
---|---|
boolean |
Returns true if the two MIME types match. |
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
filterMimeTypes
public String[] filterMimeTypes (String mimeType)
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. |
Returns | |
---|---|
String[] |
Returns an array of all matching MIME types. If there are no matching MIME types, null is returned. |
getClassificationStatus
public int getClassificationStatus ()
Returns CLASSIFICATION_COMPLETE
if text classification has been performed on the
associated ClipData
. If this is the case then getConfidenceScore(String)
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).
Returns | |
---|---|
int |
Value is CLASSIFICATION_NOT_COMPLETE , CLASSIFICATION_NOT_PERFORMED , or CLASSIFICATION_COMPLETE |
getConfidenceScore
public float getConfidenceScore (String entity)
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 TextClassifier.TYPE_UNKNOWN , TextClassifier.TYPE_OTHER , TextClassifier.TYPE_EMAIL , TextClassifier.TYPE_PHONE , TextClassifier.TYPE_ADDRESS , TextClassifier.TYPE_URL , TextClassifier.TYPE_DATE , TextClassifier.TYPE_DATE_TIME , TextClassifier.TYPE_FLIGHT_NUMBER , or android.view.textclassifier.TextClassifier.TYPE_DICTIONARY |
Returns | |
---|---|
float |
Value is between 0.0 and 1.0 inclusive |
Throws | |
---|---|
IllegalStateException |
if getClassificationStatus() is not
CLASSIFICATION_COMPLETE |
getExtras
public PersistableBundle getExtras ()
Retrieve extended data from the clip description.
Returns | |
---|---|
PersistableBundle |
the bundle containing extended data previously set with
setExtras(android.os.PersistableBundle) , or null if no extras have been set. |
See also:
getLabel
public CharSequence getLabel ()
Return the label for this clip.
Returns | |
---|---|
CharSequence |
getMimeType
public String getMimeType (int index)
Return one of the possible clip MIME types.
Parameters | |
---|---|
index |
int |
Returns | |
---|---|
String |
getMimeTypeCount
public int getMimeTypeCount ()
Return the number of MIME types the clip is available in.
Returns | |
---|---|
int |
getTimestamp
public long getTimestamp ()
Return the timestamp at which the associated ClipData
is copied to global clipboard
in the System.currentTimeMillis()
time base.
Returns | |
---|---|
long |
timestamp at which the associated ClipData is copied to global clipboard
or 0 if it is not copied to clipboard. |
hasMimeType
public boolean hasMimeType (String mimeType)
Check whether the clip description contains the given MIME type.
Parameters | |
---|---|
mimeType |
String : The desired MIME type. May be a pattern. |
Returns | |
---|---|
boolean |
Returns true if one of the MIME types in the clip description matches the desired MIME type, else false. |
isStyledText
public boolean isStyledText ()
Returns true if the first item of the associated ClipData
contains styled text, i.e.
if it contains spans such as CharacterStyle
, ParagraphStyle
, or UpdateAppearance
. Returns false if it does not, or if
there is no associated clip data.
Returns | |
---|---|
boolean |
setExtras
public void setExtras (PersistableBundle extras)
Add extended data to the clip description.
Parameters | |
---|---|
extras |
PersistableBundle |
See also:
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String |
a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
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.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |