Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – IllegalStateException:只有全屏不透明活动才能请求方向大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个从浏览器打开的活动
当设备处于横向状态时,请将我误解为错误
java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

表现

<activity android:name=".Activity.MyActivity"
        android:configChanges="orientation"
        android:screenOrientation="porTrait"
        android:theme="@style/AppTheme.Theme_Slide"
        >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.bROWSABLE" />

            <data
                android:host="xxx"
                android:scheR_913_11845@e="xxx" />
            <data
                android:host="xxx"
                android:scheR_913_11845@e="xxx" />
        </intent-filter>
    </activity>

style.xml

<style name="AppTheme.Theme_Slide" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowCloSEOnTouchOutside">false</item>
</style>

解决方法

updatE
寻找解决方

@R_675_5313@d Oreo中,你不能改变Activity的方向

<item name="android:windowIsTranslucent">true</item>

在风格.您必须先从清单中删除以下行

android:screenOrientation="porTrait"

其次,您必须将此行添加到java文件

//android O fix bug orientation
    if (android.os.build.VERSION.SDK_INT < Build.VERSION_CODEs.O) {
        setrequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTraiT);
    }

大佬总结

以上是大佬教程为你收集整理的android – IllegalStateException:只有全屏不透明活动才能请求方向全部内容,希望文章能够帮你解决android – IllegalStateException:只有全屏不透明活动才能请求方向所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。