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

Teo
  • 3,394
  • 11
  • 43
  • 73

2 Answers2

5
android:configChanges="orientation|keyboardHidden|keyboard"
Teo
  • 3,394
  • 11
  • 43
  • 73
Yashwanth Kumar
  • 28,931
  • 15
  • 65
  • 69
  • in manifest , right ? I insterted that line in each one of my activities and when I rotate the device the activities are still restarting. – Teo Oct 07 '11 at 09:25
  • it works for me , try this then android:configChanges="orientation|keyboardHidden|keyboard" – Yashwanth Kumar Oct 07 '11 at 09:28
  • yeah that was it `android:configChanges="orientation|keyboardHidden|keyboard"` – Teo Oct 07 '11 at 09:34
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..

eashdroidian
  • 33
  • 2
  • 6