Skip to content

Instantly share code, notes, and snippets.

@thetooth
Created November 26, 2019 01:27
Show Gist options
  • Save thetooth/c410f1caf4c384318396cbdf9ea061fe to your computer and use it in GitHub Desktop.
Save thetooth/c410f1caf4c384318396cbdf9ea061fe to your computer and use it in GitHub Desktop.
@Override public void onCreate(Bundle state) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
hideSystemUI();
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
@Override public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideSystemUI();
}
}
private void hideSystemUI() {
// Enables sticky immersive mode.
this.view.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment