度娘搜索下关键字,能出现好多个解决方案,我也是看了他们的然后改进的。
大佬1:https://www.jianshu.com/p/d0d907754603
大佬2:https://blog.csdn.net/starry_eve/article/details/82777160
我的问题出现在给游戏接魅族SDK的时候,在小米5手机(系统android8.0.0)上登录闪退,当然看闪退日志就是标题。
对接魅族SDK要求配置很多个activity,如
<activity
android:name="com.xxx.xxx.loader.a.ActivityN1NRNTS2"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:exported="false"
android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
这些activity在魅族SDK的依赖jar中,那么这里就不能使用大佬2的解决方案。
再看这个theme在android sdk目录下的,那么这里也不能直接使用大佬1的解决方案。
参考大佬1,修改如下
在res/style.xml中加入下面配置(第二个item也可以不要)
<style name="Meizu_Translucent_Theme" parent="@android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowDisablePreview">true</item>
</style>
然后修改activity配置
<activity
android:name="com.jspdk.mtx.mz.loader.a.ActivityN1NRTS2"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:exported="false"
android:screenOrientation="sensorLandscape"
android:theme="@style/Meizu_Translucent_Theme" />
导致的问题也很明显,就是本来是一个透明的activity,结果变成了黑屏的activity。
还有就是,这里删除android:screenOrientation="sensorLandscape"也没用,因为:Activity的风格为透明,如果调用setRequestedOrientation方法固定方向,则crash。