Orientation change notification in Android

171 views Asked by At

Trying to follow something. Boiling down to simplest: In my AndroidManifest.xml I have the following:

<application
 android:allowBackup="true"
 android:configChanges="orientation"
 ...
</application>

In my activity that runs I have this:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    Log.d("PrimesAreInP", "onConfigurationChanged called");
}

However when I change the orientation of the phone from portrait to landscape I never see the onConfigurationChanged() print. What else do I need to do to see this call?

2

There are 2 answers

5
Zubair On

Try adding this for activity tag:

<activity android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboa‌​rdHidden"

0
Sar On

I think you are missing this dude :

super.onConfigurationChanged(newConfig);

and not forget to write this line in activity tag of your menifest :

android:configChanges="orientation|screenSize"

good luck !!!