android-lifecycle icon indicating copy to clipboard operation
android-lifecycle copied to clipboard

onSaveInstnceState will not always be called

Open ndori opened this issue 10 years ago • 2 comments

http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29

in a nutshell, it won't always get called, for fragment pop it in and out from the backstack won't call it.

it will only get called if the activity is going to be destroyed and it knows about it in advance... (so orientation change - yes, opening another app then closing it - no)

ndori avatar Jun 23 '14 06:06 ndori

Good point. Perhaps it could have a better note about it not being a standard lifecycle method.

xxv avatar Aug 18 '14 14:08 xxv

A point to mention is how the behaviour changes with onSaveInstanceState() and setRetainedInstance(). See https://stackoverflow.com/questions/13420448/how-i-can-break-things-with-fragments-with-setretaininstancetrue-and-adding-th

slightfoot avatar May 29 '16 08:05 slightfoot