I want to ignore or disable savedInstanceState so that the state of current activity won't save when I go to the next activity.
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
The savedInstanceState is a reference to a Bundle object that is passed into the onCreate method of every Android Activity. Activities have the ability, under special circumstances, to restore themselves to a previous state using the data stored in this bundle.
By calling super. onCreate(savedInstanceState); , you tell the Dalvik VM to run your code in addition to the existing code in the onCreate() of the parent class. If you leave out this line, then only your code is run. The existing code is ignored completely.
In cases where the UI data to preserve is simple and lightweight, you might use onSaveInstanceState() alone to preserve your state data. Note: You can provide access to a saved state in ViewModel objects with the Saved State module for ViewModel.
Just this:
public void onCreate(Bundle savedInstanceState){
super.onCreate(null);
Or this:
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.clear();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With