set Activity Immersive Mode On - Android Activity

Android examples for Activity:Activity Feature

Description

set Activity Immersive Mode On

Demo Code


//package com.java2s;
import android.app.Activity;

import android.os.Build;
import android.view.View;

public class Main {
    public static void setImmersiveModeOn(final Activity act) {
        //enable immersive mode if device build version is at 4.4 or higher
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            final View rootView = act.getWindow().getDecorView();
            rootView.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 // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }//if/*w w  w  .  j a  v a2s. co m*/
    }
}

Related Tutorials