Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

SliceLiveData

class SliceLiveData
kotlin.Any
   ↳ androidx.slice.widget.SliceLiveData

Class with factory methods for creating LiveData that observes slices.

Summary

Nested classes

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

abstract

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

Public methods

static SliceLiveData.CachedSliceLiveData
fromCachedSlice(@NonNull context: Context, @NonNull input: InputStream, listener: SliceLiveData.OnErrorListener!)

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

static LiveData<Slice!>
fromIntent(@NonNull context: Context, @NonNull intent: Intent)

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

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

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

static LiveData<Slice!>
fromUri(@NonNull context: Context, @NonNull uri: Uri)

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

Public methods

fromCachedSlice

@NonNull static fun fromCachedSlice(@NonNull context: Context, @NonNull input: InputStream, listener: SliceLiveData.OnErrorListener!): SliceLiveData.CachedSliceLiveData

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

fromIntent

@NonNull static fun fromIntent(@NonNull context: Context, @NonNull intent: Intent): LiveData<Slice!>

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.

fromStream

@NonNull static fun fromStream(@NonNull context: Context, @NonNull input: InputStream, listener: SliceLiveData.OnErrorListener!): LiveData<Slice!>

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.

fromUri

@NonNull static fun fromUri(@NonNull context: Context, @NonNull uri: Uri): LiveData<Slice!>

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.