Android examples for android.app:Window
Detects and toggles immersive mode
import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.util.Log; import android.view.View; public class Main { /**/*from w ww . jav a 2 s . c om*/ * Detects and toggles immersive mode (also known as "hidey bar" mode). */ @TargetApi(19) public static void toggleHideyBar(Activity activity) { int uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility(); int newUiOptions = uiOptions; boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions); if (isImmersiveModeEnabled) { Log.d("toggleHideyBar", "Turning immersive mode mode off. "); } else { Log.d("toggleHideyBar", "Turning immersive mode mode on."); } // Navigation bar hiding: Backwards compatible to ICS. if (Build.VERSION.SDK_INT >= 14) { newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } // Status bar hiding: Backwards compatible to Jellybean if (Build.VERSION.SDK_INT >= 16) { newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN; } if (Build.VERSION.SDK_INT >= 19) { newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } activity.getWindow().getDecorView().setSystemUiVisibility(newUiOptions); } }