I know you can use this: android:configChanges=”orientation” to eliminate redraws on orientation changes. Although it does not in my app. I’ve read that there may be a method you need to override with it to make it work. But I think that may be overkill.
There are only two issues I do not want to happen when I rotate the screen from portrait to landscape (or the other way).
-
If the user touches an EditText, keyboard pops up. You shift orientations, and it auto-hides. I want to keep the soft keyboard along for the ride.
-
I have a ListView loading data populated from a MySQL database. It does this through an AsynTask. When I switch orientations, I do not want this task to be called.
Can I isolate these two issues, or is the first option (configChanges) the answer?
Note: A couple of these are List Activities; but the big one is a FragmentActivity with Viewpager, and a Fragment / ListFRagment (with tabs) inner class inside.
When the orientation changes the Activity is destroyed and recreated. The method you would override if using
configChangesisonConfigurationChanged.For the keyboard question, sounds like you just need to keep a track of it’s state and restore it via the
Bundlepassed inActivity.onCreate.For the second question, you could check if
onSavedInstanceState == nullto determine if you need to run theAsyncTask. You will need to save any data to theBundleinonPause.