Maintaining an object through an orientation change
One of the head-scrathers about Android for me has been that when you open the keyboard on a device with a slide-out keyboard, the current activity is totally destroyed, then rebuilt again. I understand why it’s done, since all of a sudden, you’ve got a new resolution, and a new set of capabilities, but I never knew how to differentiate an orientation change from an Activity being destroyed because you’re going to a new Activity.
An example of this might be if you have a game thread, or some process going that you don’t want to have to shut down and restart just because you suddenly have to deal with a keyboard. The solution to this is Activity’s onRetainNonConfigurationInstance() method, as described here:
http://android-developers.blogspot.com/2009/02/faster-screen-orientation-change.html
Now you know!
Comments off