Android 新导入的项目,报错:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rikkathewrold.rikkamusic/com.rikkathewrold.rikkamusic.login.mvp.view.SelectLoginActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

Only fullscreen activities can request orientation

解决方法
添加屏幕方向和透明度设置

BaseActivity一次性添加。或者在各个activity分别添加
工具方法

private boolean fixOrientation(){
    try {
        Field field = Activity.class.getDeclaredField("mActivityInfo");
        field.setAccessible(true);
        ActivityInfo o = (ActivityInfo)field.get(this);
        o.screenOrientation = -1;
        field.setAccessible(false);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}

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;
}

在super.onCreate(savedInstanceState);    方法前添加设置方法

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O && isTranslucentOrFloating()) {
        boolean result = fixOrientation();

}

super.onCreate(savedInstanceState);

附:

@Override
public void setRequestedOrientation(int requestedOrientation) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O && isTranslucentOrFloating()) {

return;
    }
    super.setRequestedOrientation(requestedOrientation);
}

Didn't find class "androidx

compile 'com.android.support:support-v4:4.4.1'

Didn‘t find class “android.view.View$OnUnhandledKeyEventListener“,Didn‘t find class “androidx相关推荐

  1. Caused by: java.lang.NoSuchMethodException: onClick_Flashlight [class android.view.View]

    原因:方法的参数忘了写: public void onClick_ToFlashlight(){} ----> public void onClick_ToFlashlight(View vie ...

  2. Android View 的onDraw 和 draw 一定会调用吗?

    探索: 为了印证这个问题,我们写了一个自定义的View,继承自LInearLayout,没有设置background. /*** =================================== ...

  3. Android studio 使用androidX后应用启动log中报Didn‘t find class “android.view.View$OnUnhandledKeyEventListener“

    Didn't find class "android.view.View$OnUnhandledKeyEventListener" Android studio 使用android ...

  4. android view可视区域,Android使用WindowManager构造悬浮view

    一般在android显示一个View都是通过Activity的setContentView设置的,但是还有一种方法,可以直接使用WindowManager在整个应用的最上层绘制我们需要显示的view, ...

  5. 【Android 修炼手册】常用技术篇 -- Android 自定义 View

    这是[Android 修炼手册]系列第 9 篇文章,如果还没有看过前面系列文章,欢迎点击 这里 查看- 预备知识 了解 android 基本开发 看完本文可以达到什么程度 学会自定义 View 以及其 ...

  6. android使用自定义,Android 自定义View的使用

    在Android开发中,很多自带的View满足不了我们的要求,所有我们可以自定义View来达到自己想要的效果 自定义View其实很简单也很好学,话不多说现在开始. 第一步:我们需要新建一个JAVA类 ...

  7. Android开发之自定义SurfaceView绘制动效音波图 | 动效音阶图 | Android自定义View

    老套路献上图: 第一张是通过播放歌曲拿到歌曲播放的数据进行动态展示的 第二张是通过定时器随机生成的数据动态展示的 先说下这个自定义view也不难很简单,就是绘制矩形,唯一的难点在于计算矩形的坐标 说下 ...

  8. android 错误记录Attempt to invoke virtual method ‘void android.view.View.setVisibility(int)‘

    android 错误记录: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null ...

  9. Android运行时候报错:android.view.InflateException: Binary XML file line #19: Binary XML file lin

    Android运行时候报错:android.view.InflateException: Binary XML file line #19: Binary XML file lin 这个问题自己大致在 ...

  10. android.view.InflateException: Binary XML file line #7: Binary XML file line #7

    错误如下 11-21 08:19:44.040 3608-3608/com.leon.oldrecyclerview E/AndroidRuntime: FATAL EXCEPTION: main   ...

最新文章

  1. PythonGUI开发:59行代码开发小型商店添加系统
  2. 14.3.1 调用系统的拍照功能
  3. SQLite中的SELECT子句
  4. 计算机网络实验报告4icmp,实验04-ip、icmp协议分析
  5. Vi编辑器的使用方法
  6. 【theano-windows】学习笔记七——logistic回归
  7. 【机器学习】Bagging和Boosting的区别(面试准备)
  8. 数据结构--单链表single linked list(无表头哨兵)重写
  9. JQUERY弹层|图片滚动|插件开发|上传 相关收藏
  10. word插入页码后只有当前页有页码
  11. mysql时区重启后失效_mysql时区问题
  12. 微信 Emoji表情代码大全
  13. 四五百蓝牙耳机哪个好?500元以内音质最好的蓝牙耳机
  14. FPGA error:buffers of the same direction cannot be placed in series.
  15. 移动通信各制式、调制的速率及频谱利用率(2G-4G)
  16. 全球竞争力报告全部数据(2006-2019年)
  17. html渐变色css3渐变,css3渐变
  18. 阿里云服务器ECS Ubuntu16.04-64-bit学习之一:配置桌面(进阶-脚本一键执行)
  19. VolgaCTF2015之lcg的writeup
  20. 【转】无线路由密码破解

热门文章

  1. [vue] 请描述下vue的生命周期是什么?
  2. 前端学习(2518):生命周期钩子
  3. 前端学习(2207):Vue-store文件夹的目录结构
  4. “约见”面试官系列之常见面试题第二十二篇之函数闭包(建议收藏)
  5. 前端学习(1874)vue之电商管理系统电商系统之修改element-ui组件的按需导入
  6. 前端学习(1376):app.use方法
  7. 前端学习(600):使用chorme devtools进行开发
  8. shiro学习(8):shiro连接数据库 三
  9. spring mvc学习(48):java判断系统是linux还是windows系统
  10. 第三十六期:学 Java 网络爬虫,需要哪些基础知识?