Created
December 28, 2017 13:08
-
-
Save guffyWave/f1095faeaa284daa0731ee9992fbb552 to your computer and use it in GitHub Desktop.
onRetainNonConfigurationInstance
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 Object onRetainNonConfigurationInstance() { | |
return this; | |
} | |
Then in YourActivity's onCreate() | |
public void onCreate(Bundle savedState) | |
{ | |
YourActivity prevActivity = (YourActivity)getLastNonConfigurationInstance(); | |
if(prevActivity!= null) { | |
// So the orientation did change | |
// Restore some field for example | |
this.myValue = prevActivity.myValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment