Search code examples
androidandroid-tabhostviewflipper

Android Viewflipper, onConfigurationChanged method never called


I am using ViewFlipper inside TabHost in my application. I am not able to control the orientation. I have written following code in the manifest file:

activity android:name=".HomeActivity" android:configChanges="orientation|keyboardHidden"

But still, the method onConfigurationChanged is never called in my activity. When my orientation is changed, the activity is recreated and reloaded every time.

EDIT: I found that ScreenSize is only applicable for api level above 11. If I control the orientation change in lower sdk version like 2.3.3, it is not working in ICS and if I control the orientation change in ICS (providing ScreenSize), 2.3.3 is not working. How to make android orientation changes compatible to all the sdk versions?


Solution

  • You are probably using targetSdkVersion < 11 therefore place in the manifest file

    android:configChanges="orientation|screenSize|keyboardHidden"
    

    insetad of

    android:configChanges="orientation|keyboardHidden"