Android 12 Developer Preview is here! Try it out, and give us your feedback!

SliceLiveData

@RequiresApi(19) 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!>
fromIntent(@NonNull context: Context, @NonNull intent: Intent, @Nullable listener: SliceLiveData.OnErrorListener?)

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.

static LiveData<Slice!>
fromUri(@NonNull context: Context, @NonNull uri: Uri, @Nullable listener: SliceLiveData.OnErrorListener?)

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.

fromIntent

@NonNull static fun fromIntent(
    @NonNull context: Context,
    @NonNull intent: Intent,
    @Nullable listener: SliceLiveData.OnErrorListener?
): 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