Java – what is’ savedinstancestate ‘?
I'm new to Android development, but I have some understanding of OOP concepts I'm trying to learn Android from a Java perspective
I understand that the savedinstancestate in oncreate () on line 9 is the declaration of the bundle class On line 10, we call the oncreate () method from the superclass
Here's what I won't interpret: on line 10, we pass savedinstancestate itself as a parameter to the oncreate () method This doesn't make sense to me because I want to pass an object of type bundle, but we won't pass a reference instead of an object of type bundle to the method
Solution
Savedinstancestate is a reference to the bundle object, which is passed to the oncreate method of each Android activity
Oncreate() is expected to be called with bundle as a parameter, so we pass savedinstancestate
Under special circumstances, the activity can use the data stored in this bundle to restore itself to its previous state If no instance data is available, savedinstancestate will be null
For example, savedinstancestate is always null when the activity is first started, but if the activity is destroyed during the loop, it may be non null because oncreate. Is called every time the activity is started or restarted
I hope I can help you