0

I need to handle device rotation in my app. At the same time, I need to have the app in landscape mode. If in the manifest file I've:

android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize"

the onConfigurationChanged method is never called.

How to handle this ?

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

            // Checks the orientation of the screen
            if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {

                viewRotate.setVisibility(View.GONE);
                viewControl.setVisibility(View.VISIBLE);

            } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){

                viewControl.setVisibility(View.GONE);
                viewRotate.setVisibility(View.VISIBLE);


            }


        }
andreasperelli
  • 1,034
  • 2
  • 11
  • 40

1 Answers1

0

You've locked the orientation in landscape, of course the onConfigurationChanged dosen't get called. Also onConfigurationChanged dosen't get called when entering the activity. Also you might want to see this answer: https://stackoverflow.com/a/18268304/3549142

Community
  • 1
  • 1