Slice.Builder

public static class Slice.Builder
extends Object

java.lang.Object
   ↳ android.app.slice.Slice.Builder


A Builder used to construct Slices

Summary

Public constructors

Slice.Builder(Uri uri)

This constructor was deprecated in API level P. TO BE REMOVED

Slice.Builder(Uri uri, SliceSpec spec)

Create a builder which will construct a Slice for the given Uri.

Slice.Builder(Slice.Builder parent)

Create a builder for a Slice that is a sub-slice of the slice being constructed by the provided builder.

Public methods

Slice.Builder addAction(PendingIntent action, Slice s, String subType)

Add an action to the slice being constructed

Slice.Builder addBundle(Bundle bundle, String subType, List<String> hints)

Add a bundle to the slice being constructed.

Slice.Builder addHints(List<String> hints)

Add hints to the Slice being constructed

Slice.Builder addIcon(Icon icon, String subType, List<String> hints)

Add an image to the slice being constructed

Slice.Builder addInt(int value, String subType, List<String> hints)

Add an integer to the slice being constructed

Slice.Builder addLong(long value, String subType, List<String> hints)

Add a long to the slice being constructed

Slice.Builder addRemoteInput(RemoteInput remoteInput, String subType, List<String> hints)

Add remote input to the slice being constructed

Slice.Builder addSubSlice(Slice slice, String subType)

Add a sub-slice to the slice being constructed

Slice.Builder addText(CharSequence text, String subType, List<String> hints)

Add text to the slice being constructed

Slice.Builder addTimestamp(long time, String subType, List<String> hints)

This method was deprecated in API level P. TO BE REMOVED.

Slice build()

Construct the slice.

Slice.Builder setCallerNeeded(boolean callerNeeded)

Tells the system whether for this slice the return value of onBindSlice(Uri, List) may be different depending on getCallingPackage() and should not be cached for multiple apps.

Slice.Builder setSpec(SliceSpec spec)

This method was deprecated in API level P. TO BE REMOVED

Inherited methods

Public constructors

Slice.Builder

Slice.Builder (Uri uri)

This constructor was deprecated in API level P.
TO BE REMOVED

Parameters
uri Uri

This value must never be null.

Slice.Builder

Slice.Builder (Uri uri, 
                SliceSpec spec)

Create a builder which will construct a Slice for the given Uri.

Parameters
uri Uri: Uri to tag for this slice.

This value must never be null.

spec SliceSpec: the spec for this slice.

Slice.Builder

Slice.Builder (Slice.Builder parent)

Create a builder for a Slice that is a sub-slice of the slice being constructed by the provided builder.

Parameters
parent Slice.Builder: The builder constructing the parent slice

This value must never be null.

Public methods

addAction

Slice.Builder addAction (PendingIntent action, 
                Slice s, 
                String subType)

Add an action to the slice being constructed

Parameters
action PendingIntent

This value must never be null.

s Slice

This value must never be null.

subType String: Optional template-specific type information

This value may be null.

Value is SUBTYPE_COLOR, SUBTYPE_CONTENT_DESCRIPTION, SUBTYPE_MAX, SUBTYPE_MESSAGE, SUBTYPE_PRIORITY, SUBTYPE_RANGE, SUBTYPE_SOURCE, SUBTYPE_TOGGLE, SUBTYPE_VALUE or SUBTYPE_LAYOUT_DIRECTION.

Returns
Slice.Builder

addBundle

Slice.Builder addBundle (Bundle bundle, 
                String subType, 
                List<String> hints)

Add a bundle to the slice being constructed.

Expected to be used for support library extension, should not be used for general development

Parameters
bundle Bundle

subType String: Optional template-specific type information

This value may be null.

Value is SUBTYPE_COLOR, SUBTYPE_CONTENT_DESCRIPTION, SUBTYPE_MAX, SUBTYPE_MESSAGE, SUBTYPE_PRIORITY, SUBTYPE_RANGE, SUBTYPE_SOURCE, SUBTYPE_TOGGLE, SUBTYPE_VALUE or SUBTYPE_LAYOUT_DIRECTION.

hints List

Value is HINT_TITLE, HINT_LIST, HINT_LIST_ITEM, HINT_LARGE, HINT_ACTIONS, HINT_SELECTED, HINT_NO_TINT, HINT_SHORTCUT, HINT_HORIZONTAL, HINT_PARTIAL, HINT_SEE_MORE, HINT_KEYWORDS, HINT_ERROR, HINT_TTL, HINT_LAST_UPDATED or HINT_PERMISSION_REQUEST.

Returns
Slice.Builder

addRemoteInput

Slice.Builder addRemoteInput (RemoteInput remoteInput, 
                String subType, 
                List<String> hints)

Add remote input to the slice being constructed

Parameters
remoteInput RemoteInput

subType String: Optional template-specific type information

This value may be null.

Value is SUBTYPE_COLOR, SUBTYPE_CONTENT_DESCRIPTION, SUBTYPE_MAX, SUBTYPE_MESSAGE, SUBTYPE_PRIORITY, SUBTYPE_RANGE, SUBTYPE_SOURCE, SUBTYPE_TOGGLE, SUBTYPE_VALUE or SUBTYPE_LAYOUT_DIRECTION.

hints List

Value is HINT_TITLE, HINT_LIST, HINT_LIST_ITEM, HINT_LARGE, HINT_ACTIONS, HINT_SELECTED, HINT_NO_TINT, HINT_SHORTCUT, HINT_HORIZONTAL, HINT_PARTIAL, HINT_SEE_MORE, HINT_KEYWORDS, HINT_ERROR, HINT_TTL, HINT_LAST_UPDATED or HINT_PERMISSION_REQUEST.

Returns
Slice.Builder

addSubSlice

Slice.Builder addSubSlice (Slice slice, 
                String subType)

Add a sub-slice to the slice being constructed

Parameters
slice Slice

This value must never be null.

subType String: Optional template-specific type information

This value may be null.

Value is SUBTYPE_COLOR, SUBTYPE_CONTENT_DESCRIPTION, SUBTYPE_MAX, SUBTYPE_MESSAGE, SUBTYPE_PRIORITY, SUBTYPE_RANGE, SUBTYPE_SOURCE, SUBTYPE_TOGGLE, SUBTYPE_VALUE or SUBTYPE_LAYOUT_DIRECTION.

Returns
Slice.Builder

build

Slice build ()

Construct the slice.

Returns
Slice

setCallerNeeded

Slice.Builder setCallerNeeded (boolean callerNeeded)

Tells the system whether for this slice the return value of onBindSlice(Uri, List) may be different depending on getCallingPackage() and should not be cached for multiple apps.

Parameters
callerNeeded boolean

Returns
Slice.Builder

setSpec

Slice.Builder setSpec (SliceSpec spec)

This method was deprecated in API level P.
TO BE REMOVED

Parameters
spec SliceSpec

Returns
Slice.Builder