0
votes

I want to support my application to support only Portrait and left Landscape mode of orientation.

If My app is in Portrait mode and user changes orientation to landscape-left, it should change to landscape mode. But If My app started in Portrait mode and user changes orientation to landscape-right, it should not change to landscape mode.

similarly It should change its mode from left-landscape to portrait.

if(screenOrientation == 0){
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else if(screenOrientation == 1){
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }

I locked the mode depending on screenOrientation value but when to unlock rotation. without unlocking it wont change its mode in any rotation.

is anyone have idea about it?

1
Without code no one can guide you where you doing wrong. - Haresh Chhelana
i have edited code with some code details i have. - Aniket

1 Answers

0
votes

add this line in manifest android:screenOrientation="sensorLandscape"

      <activity
        android:name=".MainActivity"
        android:screenOrientation="sensor" >
    </activity>