I think my ideas on activity lifecycle and bundles
are a little confused,can you help me?
Let's suppose the user opens activity A from home screen,
activity A "calls" activity B which fills the screen.
On this event onSaveInstanceState()
is called on activity A then onPause()
and onStop()
.
Since there are too many apps currently running on the system,
andorid decides to kill the process hosting activity A.
When the user navigates back to activity A,onCreate() is called an we can
use the bundle ( setted during the last call of onSaveInstaceStae() ) to restore the state.
then onStart()
,onRestoreInsanceState()
and onResume()
are called,
am I right?
Then lets suppose the user presses back key to exit from activity A
onPause()
,onStop()
and onDestory()
are called in sequence on activity A (the call of onDestroy()
could be postponed though)
onSaveInsanceState()
should not be called in this scenario.
When the user opens again activity A later on then the bundle
passed to onCreate() is null,right?
Now Suppose the user rotates screen
onSaveInsanceState()
,OnPause()
,OnStop()
, OnDestroy()
are called
then onCreate()
with bundle setted by the last call to onSaveInsanceState()
,
and then onStart(), and onRestore().
am I right?
My guess is that:
when the user creates an ativity,the bundle passed to onCreate()
is always null and onRestoreState()
is never called,but when the system creates it , for instance when it killed the activity because of low memory or because of a rotation event,the bundle passed is the one setted by the last call of onSaveInstanceState().
Is my guess right?
thanks and sorry for my poor english.
P.S. : I think onRestoreInstanceState()
is passed the same bundle is passed onCreate()
but typically state is restored using onCreate()
.