Skip to content

Instantly share code, notes, and snippets.

@nontravis
Created December 11, 2016 16:34
Show Gist options
  • Save nontravis/49d1a29ba99c769ce0bbdac39983fe53 to your computer and use it in GitHub Desktop.
Save nontravis/49d1a29ba99c769ce0bbdac39983fe53 to your computer and use it in GitHub Desktop.
//In Fragment
@Override
public void onCreate( @Nullable Bundle savedInstanceState ){
super.onCreate( savedInstanceState );
...
if( savedInstanceState != null ){
onRestoreInstanceState( savedInstanceState ); // Restore Instance State here
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Bundle saveBundle = new Bundle();
// Save Instance State here
outState.putBundle( BUNDLE_SAVE_DATA, saveBundle );
}
private void onRestoreInstanceState( Bundle savedInstanceSate ){
Bundle restoreBundle = savedInstanceSate.getBundle( BUNDLE_SAVE_DATA );
// Restore instance state here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment