Added in API level 28
Deprecated in API level 35

Slice.Builder


public static class Slice.Builder
extends Object

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


This class was deprecated in API level 35.
Slice framework has been deprecated, it will not receive any updates from ERROR(/android.os.Build.VANILLA_ICE_CREAM) and forward. If you are looking for a framework that sends displayable data from one app to another, consider using AppSearchManager.

A Builder used to construct Slices

Summary

Public constructors

Builder(Slice.Builder parent)

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

Builder(Uri uri, SliceSpec spec)

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

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 build()

Construct the slice.

Slice.Builder setCallerNeeded(boolean callerNeeded)

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

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

Added in API level 28
public 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 cannot be null.

Builder

Added in API level 28
public 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 cannot be null.

spec SliceSpec: the spec for this slice.

Public methods

addAction

Added in API level 28
public Slice.Builder addAction (PendingIntent action, 
                Slice s, 
                String subType)

Add an action to the slice being constructed

Parameters
action PendingIntent: This value cannot be null.

s Slice: This value cannot be null.

subType String: Optional template-specific type information This value may be null. Value is Slice.SUBTYPE_COLOR, Slice.SUBTYPE_CONTENT_DESCRIPTION, Slice.SUBTYPE_MAX, Slice.SUBTYPE_MESSAGE, Slice.SUBTYPE_PRIORITY, Slice.SUBTYPE_RANGE, Slice.SUBTYPE_SOURCE, Slice.SUBTYPE_TOGGLE, Slice.SUBTYPE_VALUE, or Slice.SUBTYPE_LAYOUT_DIRECTION

Returns
Slice.Builder

addBundle

Added in API level 28
public 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

Returns
Slice.Builder

addIcon

Added in API level 28
public Slice.Builder addIcon (Icon icon, 
                String subType, 
                List<String> hints)

Add an image to the slice being constructed

Returns
Slice.Builder

addInt

Added in API level 28
public Slice.Builder addInt (int value, 
                String subType, 
                List<String> hints)

Add an integer to the slice being constructed

Returns
Slice.Builder

addLong

Added in API level 28
public Slice.Builder addLong (long value, 
                String subType, 
                List<String> hints)

Add a long to the slice being constructed

Returns
Slice.Builder

addRemoteInput

Added in API level 28
public Slice.Builder addRemoteInput (RemoteInput remoteInput, 
                String subType, 
                List<String> hints)

Add remote input to the slice being constructed

Returns
Slice.Builder

addSubSlice

Added in API level 28
public Slice.Builder addSubSlice (Slice slice, 
                String subType)

Add a sub-slice to the slice being constructed

Parameters
slice Slice: This value cannot be null.

subType String: Optional template-specific type information This value may be null. Value is Slice.SUBTYPE_COLOR, Slice.SUBTYPE_CONTENT_DESCRIPTION, Slice.SUBTYPE_MAX, Slice.SUBTYPE_MESSAGE, Slice.SUBTYPE_PRIORITY, Slice.SUBTYPE_RANGE, Slice.SUBTYPE_SOURCE, Slice.SUBTYPE_TOGGLE, Slice.SUBTYPE_VALUE, or Slice.SUBTYPE_LAYOUT_DIRECTION

Returns
Slice.Builder

addText

Added in API level 28
public Slice.Builder addText (CharSequence text, 
                String subType, 
                List<String> hints)

Add text to the slice being constructed

Returns
Slice.Builder

build

Added in API level 28
public Slice build ()

Construct the slice.

Returns
Slice

setCallerNeeded

Added in API level 28
public Slice.Builder setCallerNeeded (boolean callerNeeded)

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

Parameters
callerNeeded boolean

Returns
Slice.Builder