Search code examples
androidandroid-orientation

Android: using screenOrientation in the manifest and listening to configChanges


I have a camera app that should work in both landscape modes (normal and reverse), but should not allow portrait mode. I want to get notified when the orientation change to correct the preview. So I use both these tags

android:screenOrientation="sensorLandscape"

and

android:configChanges="orientation|screenSize|keyboard|keyboardHidden"

in the manifest. But whenever the first one is set, the method

@Override
public void onConfigurationChanged(Configuration newConfig)

simply does not get called anymore in my Activity. It does when I omit the screenOrientation tag altogether. This seems crazy, is there a way to restrict screen orientations but still have the listener triggered when they change?


Solution

  • Resolved with an OrientationEventListener