Android disable landscape mode
Asked Answered
J

2

3

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 ) .

Jefe answered 7/10, 2011 at 9:11 Comment(0)
O
5
android:configChanges="orientation|keyboardHidden|keyboard"
Outstretch answered 7/10, 2011 at 9:12 Comment(3)
in manifest , right ? I insterted that line in each one of my activities and when I rotate the device the activities are still restarting.Jefe
it works for me , try this then android:configChanges="orientation|keyboardHidden|keyboard"Outstretch
yeah that was it android:configChanges="orientation|keyboardHidden|keyboard"Jefe
G
0

write a class and extend it to the activity. In that class add this code to a method. setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Then call this method to the activites to which you want to disable the landscape mode..

Gomer answered 2/4, 2014 at 15:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.