Search code examples
androidlandscapemode

Android disable landscape mode


I wish to disable the landscape view in an android application . I've used :

 <activity android:name=".SomeActivity"
              android:label="@string/app_name"
              android:screenOrientation="portrait">

It works but there is a slightly big problem . If I rotate the screen the activity restarts , and when it comes back , the screen is still in portrait mode . I want my app to completely ignore the device's position . There is no point in disabling the landscape view if when I rotate the device the activity restarts ( the screen becomes black for a few seconds , and then the activity appears again still in portrait mode ) .


Solution

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