声明:本文转自:点击打开链接
java.lang.RuntimeException:Unable to start activity ComponentInfo{net.maipeijian.xiaobihuan/com.etop.EtoVinActivity}: java.lang.IllegalStateException: Only fullscreen activities can request orientation
sdk27版本使用:if targetSdkVersion is >=27 ( > android.os.Build.VERSION_CODES.O) you get this error, they have changedActivityRecordin latest Android version adding this:
void setRequestedOrientation(int requestedOrientation) { if (ActivityInfo.isFixedOrientation(requestedOrientation) && !fullscreen
&& appInfo.targetSdkVersion > O) { throw new IllegalStateException("Only fullscreen activities can request orientation"); .... }
原因是sdk27版本使用:if targetSdkVersion is >=27 ( > android.os.Build.VERSION_CODES.O) you get this error, they have changed ActivityRecord in latest Android version adding this:
void setRequestedOrientation(int requestedOrientation) { if (ActivityInfo.isFixedOrientation(requestedOrientation) && !fullscreen
&& appInfo.targetSdkVersion > O) { throw new IllegalStateException("Only fullscreen activities can request orientation"); .... }
设置锁定坚屏setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 或者 android:screenOrientation="portrait"
//8.1不能使用透明主题
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES. O) {
this.setTheme(R.style.A);//不透明
}else {
this.setTheme(R.style.B);//透明主题
}
1.设置主题代码放在 onCreate方法中的
super.onCreate(savedInstanceState);
设置主题代码(setTheme)
setContentView(R.layout.activity);
2.manifest 中activity不要使用设置主题代码
android:theme="@style/NoTitleDialog"
我的GitHub 仅仅把自己的坑分享一下,欢迎指正。