All the sources I read have all mentioned couple of cases and concluded with "a few other cases". What are ALL the cases when the onSaveInstanceState method called in a View/Activity?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
onSaveInstanceState is called when ever activity is out of veiw.. like when u press home key, onSaveInstanceState is called.
The doc says
Also be aware that
onSaveInstanceState
can be called on a fragment directly afteronCreate
(onCreateView
,onActivityCreated
,onStart
, andonResume
will NOT be called), if the fragment is attached to an activity but not shown, then destroyed. Thus you need to be sure that everything you reference inonSaveInstanceState
is initialized inonCreate
, otherwise you risk aNullPointerException
.onSaveInstanceState() will be called by default for a view if it has an id.
google said: "The default implementation takes care of most of the UI per-instance state for you by calling onSaveInstanceState() on each view in the hierarchy that has an id".
More info here.
As per doc
This method did not call when user presses "return" button,this is one of that case..