It's happening now, watch the livestream.

SliceLiveData

public final class SliceLiveData
extends Object

java.lang.Object
   ↳ androidx.slice.widget.SliceLiveData


Class with factory methods for creating LiveData that observes slices.

Summary

Nested classes

class SliceLiveData.CachedSliceLiveData

Implementation of LiveData that provides controls over how cached vs live slices work. 

interface SliceLiveData.OnErrorListener

Listener for errors when using SliceLiveData.fromStream(Context, InputStream, OnErrorListener)

Public methods

static SliceLiveData.CachedSliceLiveData fromCachedSlice(Context context, InputStream input, SliceLiveData.OnErrorListener listener)

Same as fromStream(Context, InputStream, OnErrorListener) except returns as type SliceLiveData.CachedSliceLiveData.

static LiveData<Slice> fromIntent(Context context, Intent intent)

Produces a LiveData that tracks a Slice for a given Intent.

static LiveData<Slice> fromStream(Context context, InputStream input, SliceLiveData.OnErrorListener listener)

Produces a LiveData that tracks a Slice for a given InputStream.

static LiveData<Slice> fromUri(Context context, Uri uri)

Produces a LiveData that tracks a Slice for a given Uri.

Inherited methods

Public methods

fromCachedSlice

public static SliceLiveData.CachedSliceLiveData fromCachedSlice (Context context, 
                InputStream input, 
                SliceLiveData.OnErrorListener listener)

Same as fromStream(Context, InputStream, OnErrorListener) except returns as type SliceLiveData.CachedSliceLiveData.

Parameters
context Context

input InputStream

listener SliceLiveData.OnErrorListener

Returns
SliceLiveData.CachedSliceLiveData

fromIntent

public static LiveData<Slice> fromIntent (Context context, 
                Intent intent)

Produces a LiveData that tracks a Slice for a given Intent. To use this method your app must have the permission to the slice Uri.

Parameters
context Context

intent Intent

Returns
LiveData<Slice>

fromStream

public static LiveData<Slice> fromStream (Context context, 
                InputStream input, 
                SliceLiveData.OnErrorListener listener)

Produces a LiveData that tracks a Slice for a given InputStream. To use this method your app must have the permission to the slice Uri. This will not ask the hosting app for a slice immediately, instead it will display the slice passed in through the input. When the user interacts with the slice, then the app will be started to obtain the current slice and trigger the user action.

Parameters
context Context

input InputStream

listener SliceLiveData.OnErrorListener

Returns
LiveData<Slice>

fromUri

public static LiveData<Slice> fromUri (Context context, 
                Uri uri)

Produces a LiveData that tracks a Slice for a given Uri. To use this method your app must have the permission to the slice Uri.

Parameters
context Context

uri Uri

Returns
LiveData<Slice>