android - Why is onSaveInstanceState called when starting new activity? -
why onsaveinstancestate
called when starting new activity startactivity(intent)
, when user presses or home new activity, onrestoreinstancestate
not called?
when navigate activity activity b, activity have onsaveinstancestate()
method invoked in case activity destroyed (because system needs free resources).
when navigate activity b activity a, there few different paths code can take. if activity still , running, resume (and you'll see onresume()
called). if instead activity destroyed system while on activity b, activity need recreated. you'll see oncreate()
called system (and param savedinstancestate
non-null , populated put in onsaveinstancestate()
) other lifecycle methods happen "after" oncreate().
Comments
Post a Comment