Sequenceablepublic static class PasteData.Record extends Object implements Sequenceable
Record, which can be plain text, HTML text, URIs, and intents.
A PasteData object contains one or more records. Each record contains only one paragraph of plain text
or HTML text, a URI, or an intent.Sequenceable.Producer<T>| 限定符和类型 | 方法 | 说明 |
|---|---|---|
CharSequence |
convertToText(Context context) |
Forcibly converts the content in a pasteboard
Record object to text. |
static PasteData.Record |
createHtmlTextRecord(String htmlText) |
Creates a
Record object for PasteData#MIMETYPE_TEXT_HTML. |
static PasteData.Record |
createIntentRecord(Intent intent) |
Creates a
Record object for PasteData#MIMETYPE_TEXT_INTENT. |
static PasteData.Record |
createPlainTextRecord(CharSequence text) |
Creates a
Record object for PasteData#MIMETYPE_TEXT_PLAIN. |
static PasteData.Record |
createUriRecord(Uri uri) |
Creates a
Record object for PasteData#MIMETYPE_TEXT_URI. |
String |
getHtmlText() |
Obtains HTML text in a record.
|
Intent |
getIntent() |
Obtains an intent in a record.
|
String |
getMimeType() |
Obtains MIME types of a record.
|
CharSequence |
getPlainText() |
Obtains plain text in a record.
|
Uri |
getUri() |
Obtains an URI in a record.
|
boolean |
marshalling(Parcel parcel) |
Marshals a
Record object into a Parcel. |
boolean |
unmarshalling(Parcel parcel) |
Unmarshals a
Record object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithasFileDescriptorpublic static PasteData.Record createPlainTextRecord(CharSequence text)
Record object for PasteData#MIMETYPE_TEXT_PLAIN.text - Indicates plain text in the record.Record;
returns null if the input parameter is null.public static PasteData.Record createHtmlTextRecord(String htmlText)
Record object for PasteData#MIMETYPE_TEXT_HTML.htmlText - Indicates HTML text in the record.Record;
returns null if the input parameter is null.public static PasteData.Record createUriRecord(Uri uri)
Record object for PasteData#MIMETYPE_TEXT_URI.uri - Indicates an URI in the record.Record;
returns null if the input parameter is null.public static PasteData.Record createIntentRecord(Intent intent)
Record object for PasteData#MIMETYPE_TEXT_INTENT.intent - Indicates an intent in the record.Record;
returns null if the input parameter is null.public CharSequence getPlainText()
null if no data is contained in the record.public String getHtmlText()
null if no data is contained in the record.public Uri getUri()
null if no data is contained in the record.public Intent getIntent()
null if no data is contained in the record.public String getMimeType()
public CharSequence convertToText(Context context)
Record object to text.
This method follows the following conversion rules:
mimeType is PasteData.MIMETYPE_TEXT_PLAIN,
this method returns the plain text.
mimeType is PasteData.MIMETYPE_TEXT_HTML,
this method removes HTML elements, such as tags and tabs, and returns the plain text only.
mimeType is PasteData.MIMETYPE_TEXT_URI,
this method reads and returns the text contained in the URI. If the reading fails, null is returned.
mimeType is PasteData.MIMETYPE_TEXT_INTENT,
this method converts the Intent to a URI of the text format. For details, see
Intent.toUri().
context - Indicates the caller context,
which is used to obtain information such as DataAbilityHelper.Record object if the operation is successful;
returns null otherwise.public boolean marshalling(Parcel parcel)
Record object into a Parcel.marshalling 在接口中 Sequenceableparcel - Indicates the Parcel object for marshalling.true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel parcel)
Record object from a Parcel.unmarshalling 在接口中 Sequenceableparcel - Indicates the Parcel object for unmarshalling.true if the unmarshalling is successful; returns false otherwise.