Activity doesn't show in full screen

前端 未结 1 2061
眼角桃花
眼角桃花 2021-01-16 03:10

I defined a new Activity on my project and I have some trouble with fullScreen.

I defined in the manifest file like this:



        
相关标签:
1条回答
  • 2021-01-16 03:24

    I fond the issue. There is a method I omitted to add in question text - I didn't thought it's relevant. Because I want this activity to intercept (do not react) home button press, and for this reason I override onAttachedToWindow() method like this:

    public void onAttachedToWindow() {
        getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
        super.onAttachedToWindow();
    }
    

    And here is the issue. Some times, because of this, my activity didn't get full screen. To fix this, I don't know if this is the best way, I added a delay to this code, like this:

    public void onAttachedToWindow() {
        handler.sendEmptyMessageDelayed(100,100);
        super.onAttachedToWindow();
    }
    

    and the handler:

    public boolean handleMessage(Message msg) {
        getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
    }
    

    and this solved my issue. I hope this help someone!

    0 讨论(0)
提交回复
热议问题