Slide 26
Slide 26 text
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// LiveData
LocationLiveData locationLiveData = new LocationLiveData();
// Automatically unregistered when the activity is destroyed
// If this has an initial value, it won't be delivered yet!
locationLiveData.observe(this, this::handleLocation);
}
private void handleLocation(Location location) {
// won't receive any callbacks until the activity is started or resumed
}