Activity doesn't show in full screen

梦想的初衷 提交于 2019-12-01 13:08:10

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!