Last active
June 6, 2021 06:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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