SliceItem
@RequiresApi(value = 19)
public final class SliceItem implements VersionedParcelable
A SliceItem is a single unit in the tree structure of a Slice.
A SliceItem a piece of content and some hints about what that content means or how it should be displayed. The types of content can be:
The hints that a SliceItem are a set of strings which annotate the content. The hints that are guaranteed to be understood by the system are defined on Slice.
Summary
Public methods |
|
|---|---|
static @NonNull ParcelableSpan |
Creates a span object that identifies content that should be redacted when acquired using |
void |
fireAction(@Nullable Context context, @Nullable Intent i)Trigger the action on this SliceItem. |
PendingIntent |
|
String |
Get the format of this SliceItem. |
@NonNull List<String> |
getHints()Gets all hints associated with this SliceItem. |
IconCompat |
getIcon() |
int |
getInt() |
long |
getLong() |
@Nullable CharSequence |
Get the same content as |
Slice |
getSlice() |
String |
Get the sub-type of this SliceItem. |
CharSequence |
getText() |
boolean |
|
void |
Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated. |
void |
onPreParceling(boolean isStream)Called immediately before this object is going to be serialized, can be used to handle any custom fields that cannot be easily annotated. |
String |
toString() |
Public methods
createSensitiveSpan
public static @NonNull ParcelableSpan createSensitiveSpan()
Creates a span object that identifies content that should be redacted when acquired using getRedactedText.
fireAction
public void fireAction(@Nullable Context context, @Nullable Intent i)
Trigger the action on this SliceItem.
getAction
public PendingIntent getAction()
| Returns | |
|---|---|
PendingIntent |
The pending intent held by this |
getFormat
public String getFormat()
Get the format of this SliceItem.
The format will be one of the following types supported by the platform:
| See also | |
|---|---|
getSubType |
() |
getHints
public @NonNull List<String> getHints()
Gets all hints associated with this SliceItem.
getIcon
public IconCompat getIcon()
| Returns | |
|---|---|
IconCompat |
The icon held by this |
getInt
public int getInt()
| Returns | |
|---|---|
int |
The color held by this |
getLong
public long getLong()
| Returns | |
|---|---|
long |
The long held by this |
getRedactedText
public @Nullable CharSequence getRedactedText()
Get the same content as getText except with content that should be excluded from persistent logs because it was tagged with createSensitiveSpan.
| Returns | |
|---|---|
@Nullable CharSequence |
The text held by this |
getSlice
public Slice getSlice()
| Returns | |
|---|---|
Slice |
The slice held by this |
getSubType
public String getSubType()
Get the sub-type of this SliceItem.
Subtypes provide additional information about the type of this information beyond basic interpretations inferred by getFormat. For example a slice may contain many FORMAT_TEXT items, but only some of them may be SUBTYPE_MESSAGE.
| See also | |
|---|---|
getFormat |
getText
public CharSequence getText()
| Returns | |
|---|---|
CharSequence |
The text held by this |
hasHint
public boolean hasHint(String hint)
| Parameters | |
|---|---|
String hint |
The hint to check for |
| Returns | |
|---|---|
boolean |
true if this item contains the given hint |
onPostParceling
public void onPostParceling()
Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated.
onPreParceling
public void onPreParceling(boolean isStream)
Called immediately before this object is going to be serialized, can be used to handle any custom fields that cannot be easily annotated.