Question

I`ve faced that Activity lifecycle issue:

enter image description here

AfteronPause()Activity sets partially visible, than calls onSavedInstanceState(Bundle), but when Activity sets to visible again calls justonResume()method.

The question is why callsonSavedInstanceState(Bundle),if i can't get saved state Bundle in onResume()oronRestoreInstanceState(Bundle)(becauseonRestoreInstanceState(Bundle) is not called)?

Était-ce utile?

La solution

There is no guarantee that life-cycle methods after onPause() will be called but You may be sure all methods before onResume() will be if Activity is created/recreated. If only onResume() is called Activity was not destroyed/stopped and its state wasn't lost so You don't have to restore it.

As you can read in documentation about restoring state, onRestoreInstanceState() is called only if Activity was destroyed and after onStart().

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top