3

I have set full screen immersive mode for my android app in onResume like this:

    @Override
    public void onResume() {
    super.onResume();  
    final View decorView = getWindow().getDecorView();
    decorView.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);
     decorView.setOnSystemUiVisibilityChangeListener
            (new View.OnSystemUiVisibilityChangeListener() {
                @Override
                public void onSystemUiVisibilityChange(int visibility) { decorView.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);

                }
            });
      }

OnSystemUiVisibilityChangeListener() is also implemented to hide the bars immediately incase a user does an inward swipe. Since the app will be run on a kiosk device, it is important to ensure that the user does not have access to home/back or any system information.

The above works fine, but when a DialogFragment is shown, the system and navigation bars become visible till the dialog is visible. How can i ensure that the bars stay hidden no matter what. Also, is there a better way to handle full screen mode and disable access to system,navigation,action,app bars completely.

EDIT: I have managed to hide the bars on the dialog by using the following code in my dialog class:

@Override
public void onStart() {
    super.onStart();
    Window window = getDialog().getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    int uiOptions = 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;
    window.getDecorView().setSystemUiVisibility(uiOptions);
}

But there is a transient time where the bars get visible before sliding out of view. How can i get the bars to not show at all.

Love2Code
  • 179
  • 1
  • 10

2 Answers2

2

What about that ?

 requestWindowFeature(Window.FEATURE_NO_TITLE);
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
 WindowManager.LayoutParams.FLAG_FULLSCREEN);
Chris Sherlock
  • 931
  • 5
  • 19
1

use this inside ur onClick method...

dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); dialog.show();

    //Set the dialog to immersive
    dialog.getWindow().getDecorView().setSystemUiVisibility(
            MyActivity.this.getWindow().getDecorView().getSystemUiVisibility());

    //Clear the not focusable flag from the window
    dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
Zef
  • 53
  • 9