BasicImmersiveMode/Application/src/main/java/com/example/android/basicimmersivemode/BasicImmersiveModeFragment.java
public void toggleHideyBar() {
        // BEGIN_INCLUDE (get_current_ui_flags)
        // The UI options currently enabled are represented by a bitfield.
        // getSystemUiVisibility() gives us that bitfield.
        int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();
        int newUiOptions = uiOptions;
        // END_INCLUDE (get_current_ui_flags)
        // BEGIN_INCLUDE (toggle_ui_flags)
        boolean isImmersiveModeEnabled =
                ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
        if (isImmersiveModeEnabled) {
            Log.i(TAG, "Turning immersive mode mode off. ");
        } else {
            Log.i(TAG, "Turning immersive mode mode on.");
        }

        // Immersive mode: Backward compatible to KitKat (API 19).
        // Note that this flag doesn't do anything by itself, it only augments the behavior
        // of HIDE_NAVIGATION and FLAG_FULLSCREEN.  For the purposes of this sample
        // all three flags are being toggled together.
        // This sample uses the "sticky" form of immersive mode, which will let the user swipe
        // the bars back in again, but will automatically make them disappear a few seconds later.
        newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
        newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
        //END_INCLUDE (set_ui_flags)
    }
/**
     * Detects and toggles immersive mode.
     */
Detects and toggles immersive mode.
Detects and toggles immersive mode .
public void toggleHideyBar() {
        int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();
        int newUiOptions = uiOptions;
        boolean isImmersiveModeEnabled =
                ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
        if (isImmersiveModeEnabled) {
            Log.i(TAG, "Turning immersive mode mode off. ");
        } else {
            Log.i(TAG, "Turning immersive mode mode on.");
        }
        newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
        newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
    }
public void toggleHideyBar ( ) { int uiOptions = getActivity ( ) . getWindow ( ) . getDecorView ( ) . getSystemUiVisibility ( ) ; int newUiOptions = uiOptions ; boolean isImmersiveModeEnabled = ( ( uiOptions | View . SYSTEM_UI_FLAG_IMMERSIVE_STICKY ) == uiOptions ) ; if ( isImmersiveModeEnabled ) { Log . i ( TAG , "Turning immersive mode mode off. " ) ; } else { Log . i ( TAG , "Turning immersive mode mode on." ) ; } newUiOptions ^= View . SYSTEM_UI_FLAG_HIDE_NAVIGATION ; newUiOptions ^= View . SYSTEM_UI_FLAG_FULLSCREEN ; newUiOptions ^= View . SYSTEM_UI_FLAG_IMMERSIVE_STICKY ; getActivity ( ) . getWindow ( ) . getDecorView ( ) . setSystemUiVisibility ( newUiOptions ) ; }
Detects and toggles immersive mode.
Detects and toggles immersive mode .
// BEGIN_INCLUDE (get_current_ui_flags) // The UI options currently enabled are represented by a bitfield. // getSystemUiVisibility() gives us that bitfield. // END_INCLUDE (get_current_ui_flags) // BEGIN_INCLUDE (toggle_ui_flags) // Immersive mode: Backward compatible to KitKat (API 19). // Note that this flag doesn't do anything by itself, it only augments the behavior // of HIDE_NAVIGATION and FLAG_FULLSCREEN.  For the purposes of this sample // all three flags are being toggled together. // This sample uses the "sticky" form of immersive mode, which will let the user swipe // the bars back in again, but will automatically make them disappear a few seconds later. //END_INCLUDE (set_ui_flags)