onConfigChanged() NOT called when device orientation changes

1.7k Views Asked by At

I'm having problems capturing the orientation changes in my app. I want to prevent my app form being restarted when the device is re-orientated.

There are 3 Activities in my app all together (the third being FragmentActivity). The main user interaction is through the FragmentActivity.

I have altered the manifest so that ALL activities have the following attribute:

android:configChanges="orientation"

I have also overridden the onConfigurationChanged() method in all activities and to see if it is actually getting called I have included a Log.i() statement but nothing is ever reported.

I'm currently testing this with the Emulator and orientation changes are reported when I do a CTRL+F12.

I/ActivityManager( 67): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=10}

Is there something I am mising?

1

There are 1 best solutions below

3
On BEST ANSWER

from: http://developer.android.com/guide/topics/resources/runtime-changes.html

Caution: Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation. Thus, if you want to prevent runtime restarts due to orientation change when developing for API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), you must include the "screenSize" value in addition to the "orientation" value. That is, you must decalare android:configChanges="orientation|screenSize". However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).