views:

391

answers:

1

Is there a way to lock orientation during runtime? For example I'd like to allow the user to lock the screen to landscape if the user currently in landscape and toggle the menu option.

+5  A: 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

Called on an activity, will lock it to landscape. Look for the other flags in the ActivityInfo class. You can lock it back to portrait or make it sensor/slider driven.

More info here: http://www.devx.com/wireless/Article/40792

haseman
Ok thanks. This works great. That will get the current orientation.getResources().getConfiguration().orientation
Jared