Min target must be less than 14 when WindowManager.LayoutParams.TYPE_KEYGUARD used

后端 未结 1 1534
执念已碎
执念已碎 2021-01-12 06:43

I am trying to prevent status bar expansion and I have used some examples where people are trying to override the home button. All solutions point to using WindowMana

相关标签:
1条回答
  • 2021-01-12 07:08

    Update onAttachedToWindow as shown below and try

    @Override
    public void onAttachedToWindow() { 
        if (!GlobalVars.testing) {
           GlobalVars.preventStatusBarExpansion(this);
        }
        super.onAttachedToWindow();
    }
    

    and add update oncreate with

     @Override
     protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   WindowManager.LayoutParams.FLAG_FULLSCREEN);
        this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
        ...
     }
    

    For Api above 14 use

    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
    
    0 讨论(0)
提交回复
热议问题