Skip to content

Instantly share code, notes, and snippets.

@guffyWave
Created December 28, 2017 13:08
Show Gist options
  • Save guffyWave/f1095faeaa284daa0731ee9992fbb552 to your computer and use it in GitHub Desktop.
Save guffyWave/f1095faeaa284daa0731ee9992fbb552 to your computer and use it in GitHub Desktop.
onRetainNonConfigurationInstance
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