gpt4 book ai didi

java - 检测状态栏何时重新出现

转载 作者:太空宇宙 更新时间:2023-11-04 13:33:37 25 4
gpt4 key购买 nike

我的应用程序以全屏运行(沉浸式模式)。

状态栏隐藏在顶部。

某些三星手机配有手写笔。如果笔被移除,状态栏会重新出现并且不会消失。

我尝试为此事件添加监听器,但它没有被调用。

 View decorView = getActivity().getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener
(new View.OnSystemUiVisibilityChangeListener()
{
@Override
public void onSystemUiVisibilityChange(int visibility) {
// Note that system bars will only be "visible" if none of the
// LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
// TODO: The system bars are visible. Make any desired
// adjustments to your UI, such as showing the action bar or
// other navigational controls.

System.out.print("Change event");
} else {
// TODO: The system bars are NOT visible. Make any desired
// adjustments to your UI, such as hiding the action bar or
// other navigational controls.
System.out.print("Change event");
}
}
});

你知道我如何知道状态栏是否重新出现吗?

最佳答案

在我的 Activity 中,我这样做是为了让它重新隐藏状态栏:

@Override
public void onWindowFocusChanged(boolean hasFocus)
{
System.out.println("Gotcha");
super.onWindowFocusChanged(hasFocus);

final Handler handler = new Handler();
handler.postDelayed(new Runnable()
{
@Override
public void run() {
System.out.println("Hiding");
_root.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}, 6000);
}

关于java - 检测状态栏何时重新出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31930874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com