This is a really good question.
Looking at the documents for onSaveInstanceState / onRestoreInstanceState, their purpose (and therefore the default behavior of the implementations) is to preserve the view state of any kind with an identifier. Examples, if the checkbox is selected, which beacon in the radio group is selected, etc.
What is also indicated in the documents is that the package created / saved for onSaveInstanceState is transmitted both onCreate and onRestoreInstanceState (more about this at once) when the activity is "re-set".
I assume that since action 1 is hidden during rotation, onRestoreInstanceState is not called because there is no โviewโ (ie it cannot be seen / viewed). In addition, it is quite possible to have 2 completely different layout files for a portrait / landscape, which could potentially have different user interface elements with different identifiers.
As a result, I would say if you want to use the Bundle in onSaveInstanceState to save your own data, then you need to add additional logic to your onCreate (in step 1) to process your own data there (just like conditionally in onRestoreInstanceState).
In particular, you could save the field of the "last known" orientation, so that onCreate knows that it needs to process your own data, because the orientation has changed, and not rely on the called onRestoreInstanceState.
Does that make sense? This is the only way to interpret logic.
source share