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

CachedSliceLiveData

class CachedSliceLiveData : LiveData<Slice!>
kotlin.Any
   ↳ androidx.lifecycle.LiveData<androidx.slice.Slice>
   ↳ androidx.slice.widget.SliceLiveData.CachedSliceLiveData

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

Summary

Public methods

open Unit

Moves this CachedSliceLiveData into a "live" state, causing the providing app to start up and provide an up to date version of the slice.

open Unit

Generally the InputStream are parsed asynchronously once the LiveData goes into the active state.

Protected methods

open Unit

open Unit

Inherited functions

Public methods

goLive

open fun goLive(): Unit

Moves this CachedSliceLiveData into a "live" state, causing the providing app to start up and provide an up to date version of the slice. After calling this method the slice will always be pinned as long as this LiveData is in the active state.

If the slice has already received a click or goLive() has already been called, then this method will have no effect.

Once goLive() has been called, there is no way to reverse it, this LiveData will then behave the same way as one created using fromUri(Context, Uri).

parseStream

open fun parseStream(): Unit

Generally the InputStream are parsed asynchronously once the LiveData goes into the active state. When this is called, regardless of state, the slice will be read from the input stream and then the input stream's reference will be released when finished.

Calling parseStream() multiple times or after the stream has already been parsed asynchronously will have no effect.

Protected methods

onActive

protected open fun onActive(): Unit

onInactive

protected open fun onInactive(): Unit