我在清单文件中设置了一个仅支持竖屏方向的活动。但我需要根据条件取消这个限制。那么,如何通过编程实现取消方向限制?
更新:我的当前设置如下:
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:screenOrientation="portrait"
android:configChanges="orientation">
/**
* Defines whether the device being used is a tablet and if so adds horizontal orientation option.
*/
protected void _updateScreenOrientationModes(){
if(((MyApplication) getApplication())._isTablet == true)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}