Back to project page kickflip-android-sdk.
The source code is released under:
Apache License
If you think the Android project kickflip-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package io.kickflip.sdk.activity; /* w ww . j a va 2 s. co m*/ import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import static io.kickflip.sdk.Kickflip.isKitKat; /** * @hide */ public abstract class ImmersiveActivity extends Activity { public static final String TAG = "ImmersiveActivity"; private boolean mUseImmersiveMode = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); } @Override protected void onResume() { super.onResume(); hideSystemUi(); } /** * If true, use Android's Immersive Mode. If false * use the "Lean Back" experience. * @see <a href="https://developer.android.com/design/patterns/fullscreen.html">Android Full Screen docs</a> * @param useIt */ public void setUseImmersiveMode(boolean useIt) { mUseImmersiveMode = useIt; } private void hideSystemUi() { if (!isKitKat() || !mUseImmersiveMode) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else if (mUseImmersiveMode) { setKitKatWindowFlags(); } } @TargetApi(Build.VERSION_CODES.KITKAT) @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (isKitKat() && hasFocus && mUseImmersiveMode) { setKitKatWindowFlags(); } } @TargetApi(Build.VERSION_CODES.KITKAT) private void setKitKatWindowFlags() { getWindow().getDecorView().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 ); } }