- Back traces starts.
- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vlion.xuehua/com.vlion.xuehua.activity.SplashActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
- at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3303)
- at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
- at android.app.ActivityThread.-wrap12(Unknown Source:0)
- at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
- at android.os.Handler.dispatchMessage(Handler.java:108)
- at android.os.Looper.loop(Looper.java:166)
- at android.app.ActivityThread.main(ActivityThread.java:7529)
- at java.lang.reflect.Method.invoke(Native Method)
- at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
- Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
- at android.app.Activity.onCreate(Activity.java:1081)
- at androidx.core.app.ComponentActivity.onCreate(ComponentActivity.java:85)
- at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:154)
- at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:312)
- at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:115)
- at com.vlion.xuehua.activity.BaseActivity.onCreate(BaseActivity.java:76)
- at com.vlion.xuehua.activity.SplashActivity.onCreate(Native Method)
- at android.app.Activity.performCreate(Activity.java:7383)
- at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
- at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256)
- ... 9 more
- Back traces ends.
这个问题是Android 版本的适配问题;
android 8.0 (API=26) 适配遇到的两个问题
解决方法:有两种,根据需求选择其一,或者两个一起用也行
(横屏方向问题)
(1)去掉android:screenOrientation;
(主题 样式)
(2)android:windowIsTranslucent 改为false; 如果需要透明的设置加上android:windowDisablePreview =true;
在项目res目录下创建values-v26/styles.xml;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppTheme.Splash" parent="AppTheme"> <item name="android:windowActionBar">false</item> <item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> <!-- 适配android手机系统8.0(api26),Only fullscreen opaque activities can request orientation --> <!--用背景图消除启动白屏--> <item name="android:windowBackground">@mipmap/qhao</item> <item name="android:windowIsTranslucent">false</item> <item name="android:windowDisablePreview">true</item> </style> </resources> |