While developing a client survey app for a tablet I realized I have to disable the notification panel from being pulled & hide bottom navigation just in case, for all those funny clients out there trying to be a smart ***.
I am working with a non rooted device so using a reflection like in this answer isn't an option.
And while adding
getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
will do the trick, it will also disable everything else.
I started by requesting full screen for the app just to hide the top bar but this didn't do anything to the bottom navigation bar.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Therefore I resorted to using Immersive Full-Screen Mode. It does hide both top and bottom bars but when the user swipes up or down, they appear again.
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
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_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
The device runs on Android 4.4