The problem is that you are losing the "state" of the application. In the PLO, what is a state? Variables! Exactly! Therefore, when you lose the data of your variables.
Now here is what you can do, find variables that lose their state.

When you rotate your device, your current activity is completely destroyed, i.e. passes through onSaveInstanceState () onPause() onStop() onDestroy() , and a new action is created completely, which passes through onCreate() onStart() onRestoreInstanceState .
Two methods are shown in bold, onSaveInstanceState () saves an instance of the current activity that will be destroyed. onRestoreInstanceState This method restores the saved state of a previous action. Thus, you will not lose the previous state of the application.
Here is how you use these methods.
@Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { super.onSaveInstanceState(outState, outPersistentState); outState.putString("theWord", theWord); // Saving the Variable theWord outState.putStringArrayList("fiveDefns", fiveDefns); // Saving the ArrayList fiveDefns } @Override public void onRestoreInstanceState(Bundle savedInstanceState, PersistableBundle persistentState) { super.onRestoreInstanceState(savedInstanceState, persistentState); theWord = savedInstanceState.getString("theWord"); // Restoring theWord fiveDefns = savedInstanceState.getStringArrayList("fiveDefns"); //Restoring fiveDefns }
DeeJay Jul 25 '17 at 5:07 on 2017-07-25 05:07
source share