Member-only story

Exploring Android LiveData Usages and Behaviors

Simple app to demonstrate Android lifecycle-aware LiveData usages and behaviors — setValue(), postValue(), observe(), and observeAsState().

Vincent Tsen
6 min readNov 11, 2022

This is part of the asynchronous flow series:

Android LiveData is observable and lifecycle-aware data.

Assuming the lifecycle owner is an activity, lifecycle-aware means it will only send updates to the UI when the activity is active. Activity is active means the UI is visible either in the background (started state) or in the foreground (resumed state).

LiveData also automatically removes all Observer objects when the activity is destroyed.

Basic LiveData Usages

Emit LiveData — setValue() / postValue()

--

--

No responses yet