The recommended way to save state across rotations is to save them on the outState. This is accomplished by overriding the onSaveInstanceState
method. This method gives you a Bundle outState
object that you can add Parcelable
and Serializable
objects to. This should work fine for your Intent
object since it implements Parcelable
but it may not work for say Handler
because it only extends Object
.
Another solution is to make these members static. However, be very careful if you decide to do this. Make sure that the value of the static member never holds on to a Context
or a view hierarchy, etc, or you could easily introduce memory leaks.
If neither of these is acceptable to you, there is the option suggested by Tushar. However, unless you're careful this will make your life very difficult very fast. A large reason why activities are destroyed and re-created is so that resources can be re-loaded. So if you have layouts, strings, colors, dimens, or basically any resource specifically for landscape, or tablets, or different versions, you'll have to reload the entire UI yourself.