Issue
Docs describes when onRestoreInstanceState
IS called:
This method is called after
onStart()
when the activity is being re-initialized from a previously saved state, given here in savedInstanceState. (...) This method is called betweenonStart()
andonPostCreate(Bundle)
. This method is called only when recreating an activity; the method isn't invoked ifonStart()
is called for any other reason.
I'm super curious what does "onStart()
is called for any other reason" mean in context of onRestoreInstanceState
?
Solution
The normal lifecycle of an Activity
looks like this:
- onCreate()
- .
- onStart()
- onResume()
- onPause()
- onStop()
- .
- onDestroy()
The lifecycle callbacks between onStart()
and onStop()
can occur over and over again if the Activity
is completely obscured by another Activity
. In this case, onStop()
is called when the Activity
is completely obscured by another Activity
. When the Activity
is made visible again, onStart()
will be called without onRestoreInstanceState()
being called because the Activity
is not being recreated.
Answered By - David Wasser
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.