12

it is possible to set the orientation of an activity in the manifest file.

but is it also possible to do it from code? if so, how?

thanks!

clamp
  • 33,000
  • 75
  • 203
  • 299

1 Answers1

26
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Cristian
  • 198,401
  • 62
  • 356
  • 264
  • 2
    thanks, do you also know if it is possible to keep the activity locked in this orientation no matter how the device is tilted? – clamp Nov 25 '10 at 13:51
  • 2
    FWIW to force the activity into a single orientation you can use this `android:screenOrientation="portrait"` in your AndroidManifest.xml on any activities you want to lock. – Brett Duncavage Apr 05 '13 at 02:24
  • And how to do it programatically, Brett? If I add a "Lock screen orientation" in my settings or menu, it would be nice to be able to do it. – A.Grandt Aug 07 '13 at 07:49