我正在创建我的第一个全屏应用,它看起来很棒,但它保持屏幕清醒,我不想这样做。我不明白为什么它一开始就保持清醒,所以我该怎么办?我应该在设置标志后清除View.KEEP_SCREEN_ON
吗?我很抱歉,如果以前曾经问过,但我找不到答案。谢谢!
以下是我在活动中设置的标志:
mDecorView = getWindow().getDecorView();
// call before setContentView to avoid system bars briefly showing
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
System.out.println("checking os version");
if (currentapiVersion >= Build.VERSION_CODES.KITKAT) {
System.out.println("KitKat or newer");
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
);
} else{
System.out.println("Older than KitKat");
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}