Android 8.0 Only fullscreen activities can request orientation 崩溃的解决
8.0系统上微信登录、支付出现问题,但8.0系统以下微信登录、支付没问题时。
崩溃产生前提条件:
当 targetSdkVersion 为27时,且运行在 8.0的机器上时,运行在8.0以下的机器不会报错,或者targetSdkVersion修改为27以下也不会报错。
崩溃场景还原:
不管Activity是不是全屏,只要在Activity中设置竖屏:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
并且 Acitivity的 Theme 中有true
崩溃是什么,就会报下面这个错误,导致崩溃。
java.lang.IllegalStateException: Only fullscreen activities can request orientation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
或者:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zhangzhongyun.track/com.zhangzhongyun.track.wxapi.WXEntryActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
转自:https://www.colabug.com/2950970.html