Android activities have a pair of methods onRetainNonConfigurationInstance()/getLastNonConfigurationInstance()
for keeping objects expensive for load during configuration changes.
What should be a nice behavior for fragments in such case?
Is setRetainInstance() a solution?
What about usage of configuration-specific resources after setting it to true?
Thank you.
If you need to support orientation change, say because you need a different layout, then I have found
setRetainInstanceworks for me making use ofonSaveInstanceStateif need be, using the saved state info inonCreateVieworonActivityCreated.With regard configuration specific resources, these won’t be affected by setting
setRetainInstanceyou’ll still get access to the correct resources for your orientation etc.inonCreateViewand so forth after an orientation change.