public static class ClipData.Item extends Object
The types than an individual item can currently contain are:
Constructor and Description |
---|
Item(CharSequence text)
Create an Item consisting of a single block of (possibly styled) text.
|
Item(CharSequence text,
Intent intent,
Uri uri)
Create a complex Item, containing multiple representations of
text, Intent, and/or URI.
|
Item(CharSequence text,
String htmlText)
Create an Item consisting of a single block of (possibly styled) text,
with an alternative HTML formatted representation.
|
Item(CharSequence text,
String htmlText,
Intent intent,
Uri uri)
Create a complex Item, containing multiple representations of
text, HTML text, Intent, and/or URI.
|
Item(ClipData.Item other) |
Item(Intent intent)
Create an Item consisting of an arbitrary Intent.
|
Item(Uri uri)
Create an Item consisting of an arbitrary URI.
|
Modifier and Type | Method and Description |
---|---|
String |
coerceToHtmlText(Context context)
Turn this item into HTML text, regardless of the type of data it
actually contains.
|
CharSequence |
coerceToStyledText(Context context)
Like
coerceToHtmlText(Context) , but any text that would
be returned as HTML formatting will be returned as text with
style spans. |
CharSequence |
coerceToText(Context context)
Turn this item into text, regardless of the type of data it
actually contains.
|
String |
getHtmlText()
Retrieve the raw HTML text contained in this Item.
|
Intent |
getIntent()
Retrieve the raw Intent contained in this Item.
|
CharSequence |
getText()
Retrieve the raw text contained in this Item.
|
Uri |
getUri()
Retrieve the raw URI contained in this Item.
|
void |
toShortString(StringBuilder b) |
void |
toShortSummaryString(StringBuilder b) |
String |
toString()
Returns a string representation of the object.
|
public Item(ClipData.Item other)
public Item(CharSequence text)
public Item(CharSequence text, String htmlText)
public Item(Intent intent)
public Item(Uri uri)
public Item(CharSequence text, Intent intent, Uri uri)
public Item(CharSequence text, String htmlText, Intent intent, Uri uri)
public CharSequence getText()
public String getHtmlText()
public Intent getIntent()
public Uri getUri()
public CharSequence coerceToText(Context context)
The algorithm for deciding what text to return is:
getText()
is non-null, return that.
getUri()
is non-null, try to retrieve its data
as a text stream from its content provider. If this succeeds, copy
the text into a String and return it. If it is not a content: URI or
the content provider does not supply a text representation, return
the raw URI as a string.
getIntent()
is non-null, convert that to an intent:
URI and return it.
context
- The caller's Context, from which its ContentResolver
and other things can be retrieved.public CharSequence coerceToStyledText(Context context)
coerceToHtmlText(Context)
, but any text that would
be returned as HTML formatting will be returned as text with
style spans.context
- The caller's Context, from which its ContentResolver
and other things can be retrieved.public String coerceToHtmlText(Context context)
The algorithm for deciding what text to return is:
getHtmlText()
is non-null, return that.
getText()
is non-null, return that, converting to
valid HTML text. If this text contains style spans,
Html.toHtml(Spanned)
is used to
convert them to HTML formatting.
getUri()
is non-null, try to retrieve its data
as a text stream from its content provider. If the provider can
supply text/html data, that will be preferred and returned as-is.
Otherwise, any text/* data will be returned and escaped to HTML.
If it is not a content: URI or the content provider does not supply
a text representation, HTML text containing a link to the URI
will be returned.
getIntent()
is non-null, convert that to an intent:
URI and return as an HTML link.
context
- The caller's Context, from which its ContentResolver
and other things can be retrieved.public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public void toShortString(StringBuilder b)
public void toShortSummaryString(StringBuilder b)