OnConfigurationChanged not getting call at any time in android

I created a sample orientation checker program. If portrait mode and I tilt the phone the other way around, I want my sample app to go back. After reading a large number of questions on this issue: "Acquired we need to use:

   onConfigurationChanged(Configuration newConfig) 

I tried the following:

    @Override
public void onConfigurationChanged(Configuration newConfig) 
{
    super.onConfigurationChanged(newConfig);

    Configuration c = getResources().getConfiguration();

    Log.e("Config",""+c);

    if (c.orientation == Configuration.ORIENTATION_PORTRAIT) 
    {
        // portrait

        Log.e("On Config Change","portrait");

    } 
    else if (c.orientation == Configuration.ORIENTATION_LANDSCAPE) 
    {
        // landscape
        Log.e("On Config Change","LANDSCAPE");

    }
}

manifest.xml

android:configChanges="orientation" 

even tried it

android:configChanges="orientation|screensize"

Strange I do not receive logs inside the OnConfigurationChange method.

Not sure. What is the problem?

I use a minimum of api 8 to target Api 18.

Can someone help me with this?

Thank!

+3
source share
3 answers

API 19 (4.4 kitkat) layoutDirection 17.

:

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|layoutDirection"

'layoutDirection'

+4

.

screenOrientation :

android:screenOrientation="sensor"

.

+2

manifest.xml : configChanges = " | keyboardHidden" , .

0

All Articles