lightbulb_outline Please take our October 2018 developer survey. Start survey
added in version 1.0.0
belongs to Maven artifact androidx.slice:slice-view:1.0.0

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

interface SliceLiveData.OnErrorListener

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

Public methods

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

fromIntent

added in version 1.0.0
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

added in version 1.0.0
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

added in version 1.0.0
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>