Skip to content

Instantly share code, notes, and snippets.

@joseprl89
Last active June 6, 2021 06:14
Show Gist options
  • Save joseprl89/eb5872966b61aae380efe59f28c086d6 to your computer and use it in GitHub Desktop.
Save joseprl89/eb5872966b61aae380efe59f28c086d6 to your computer and use it in GitHub Desktop.
How SupportActicity implements LifecycleOwner for Internals of Android Architecture Components Part II- LiveData
public class SupportActivity extends Activity implements LifecycleOwner {
...
private LifecycleRegistry mLifecycleRegistry = new LifecycleRegistry(this);
...
@Override
protected void onSaveInstanceState(Bundle outState) {
mLifecycleRegistry.markState(Lifecycle.State.CREATED);
super.onSaveInstanceState(outState);
}
...
@Override
public Lifecycle getLifecycle() {
return mLifecycleRegistry;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment