Monday, July 16, 2012

Change the desired orientation of activity: setRequestedOrientation()

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


public void setRequestedOrientation(int requestedOrientation) is used to change the desired orientation of this activity. If the activity is currently in the foreground or otherwise impacting the screen orientation, the screen will immediately be changed (possibly causing the activity to be restarted). Otherwise, this will be used the next time the activity is visible.

Where requestedOrientation is an orientation constant:ActivityInfo.screenOrientation.

Related: How to set orientation of activity/application in AndroidManifest.xml



No comments:

Post a Comment