1

I am using

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);

to lock my app screen(programmatically), but in some devices if i call this method in landscape it rotate to portrait instead of locking the screen.

Any idea what goes wrong?

YosiFZ
  • 7,792
  • 21
  • 114
  • 221
  • Do it in your manifest if it's *always* supposed to be that way. http://stackoverflow.com/questions/4675750/lock-screen-orientation-android – ChiefTwoPencils Dec 24 '14 at 10:53
  • but i want that my app will support both landscape and portrait but i some cases to lock it(pressing a button for example) – YosiFZ Dec 24 '14 at 10:59

2 Answers2

1

Use this -

<activity
            android:name="Your activity"
            android:screenOrientation="portrait" >
yuva ツ
  • 3,707
  • 9
  • 50
  • 78
0

In your XML file for your Activity,add android:orientation="horizontal"

Hayden
  • 407
  • 1
  • 6
  • 15