One of the most daunting and frustrating aspects of Android programming is handling the Activities Cycle after a screen orientation change. The game app I have been working on for many months works just fine in either orientation if I do not change orientations -- I can play game after game for hours without any problems if I do not change orientations. And I have been able to handle many aspects of restoring the game after a screen orientation change, but I still have problems with some objects that are not initialized or which already have a parent when I change orientations. Adding tons of IF statements to determine if objects are already initialized before possibly re-initializing them (which I have been recently doing) seems like something that should not be necessary.
My question is: what is the best way to handle restoring objects after an orientation change? Is it best to re-load ALL layouts (my current App has 20 layouts, which would probably take considerable time between orientation changes), and generate associated sub-views on Resume, but keep the associated backpanels into which those layouts and views are loaded invisible until later needed? Or is there some other/better way to restore objects?
My apologies for not being able to provide an exported ZIP file as the current App is way too large to do so to show the problems I'm encountering, and it may not be possible to cut out sections of my code to be able to make an exportable ZIP file because this may mask the problems I am encountering.
My question is: what is the best way to handle restoring objects after an orientation change? Is it best to re-load ALL layouts (my current App has 20 layouts, which would probably take considerable time between orientation changes), and generate associated sub-views on Resume, but keep the associated backpanels into which those layouts and views are loaded invisible until later needed? Or is there some other/better way to restore objects?
My apologies for not being able to provide an exported ZIP file as the current App is way too large to do so to show the problems I'm encountering, and it may not be possible to cut out sections of my code to be able to make an exportable ZIP file because this may mask the problems I am encountering.
Last edited: