- Android8.0 Only fullscreen activ
- Android 8.0采坑心得
- 【异常】Only fullscreen opaque activ
- Only fullscreen activities can r
- Only fullscreen activities can r
- Only fullscreen activities can r
- Only fullscreen activities can r
- Only fullscreen activities can r
- Only fullscreen activities can r
- Only fullscreen activities can r
今天遇到一个非常奇葩的问题,AS里面血红色的Log~
Only fullscreen activities can request orientation?
翻阅资料之后发现,原来是google的大神们为了赶工8.0,rom里面遗留的Bug。
解决方案如下:
1.去掉透明activity里面设置方向的所有静态的和动态的配置。
2.在BaseActivity里面编写如下2个方法:
private boolean isTranslucentOrFloating(){
boolean isTranslucentOrFloating = false;
try {
int [] styleableRes = (int[]) Class.forName("com.android.internal.R$styleable").getField("Window").get(null);
final TypedArray ta = obtainStyledAttributes(styleableRes);
Method m = ActivityInfo.class.getMethod("isTranslucentOrFloating", TypedArray.class);
m.setAccessible(true);
isTranslucentOrFloating = (boolean)m.invoke(null, ta);
m.setAccessible(false);
} catch (Exception e) {
e.printStackTrace();
}
return isTranslucentOrFloating;
}
@Override
public void setRequestedOrientation(int requestedOrientation) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O && isTranslucentOrFloating()) {
return;
}
super.setRequestedOrientation(requestedOrientation);
}
收工!!!
原因追溯参考文章
https://zhuanlan.zhihu.com/p/32190223
网友评论