void android.app.Activity.setRequestedOrientation(int requestedOrientation)
官方API解释:
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.
中文大意:
改变activity的期望的方向。如果activity 目前在前台或以其他方式影响屏幕的方向,屏幕将立即被改变(可能导致活动重新启动)。否则,这将在activity 下一次可见时使用。
//设横屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);