Teo
Teo

Reputation: 3442

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

Upvotes: 3

Views: 4952

Answers (2)

eashdroidian
eashdroidian

Reputation: 33

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

Upvotes: 0

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

android:configChanges="orientation|keyboardHidden|keyboard"

Upvotes: 5

Related Questions