Example usage for android.view Window addFlags

List of usage examples for android.view Window addFlags

Introduction

In this page you can find the example usage for android.view Window addFlags.

Prototype

public void addFlags(int flags) 

Source Link

Document

Convenience function to set the flag bits as specified in flags, as per #setFlags .

Usage

From source file:Main.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private static void setTranslucentStatusBarKiKat(Window window) {
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}

From source file:Main.java

public static void requestFullscreen(final Activity pActivity) {
    final Window window = pActivity.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    window.requestFeature(Window.FEATURE_NO_TITLE);
}

From source file:Main.java

public static void requestFullscreen(final Activity mActivity) {
    final Window window = mActivity.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    window.requestFeature(Window.FEATURE_NO_TITLE);
}

From source file:Main.java

public static void setStatusBarColor(Activity activity, int colorResource) {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = activity.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(colorResource);
    }// w w  w  .j  a  v  a  2  s . c  o  m
}

From source file:Main.java

/**
 * force show virtual menu key </br>
 * must call after setContentView() //from w  w w . jav a 2 s. c  om
 * @param window you can use getWindow()
 */
public static void forceShowMenuKey(Window window) {
    try {
        window.addFlags(WindowManager.LayoutParams.class.getField("FLAG_NEEDS_MENU_KEY").getInt(null));
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Force screen to turn on if the phone is asleep.
 *
 * @param context The current Context or Activity that this method is called from
 *//* w  ww  . java  2  s.  c om*/
public static void turnScreenOn(Activity context) {
    try {
        Window window = context.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
        window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
        window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    } catch (Exception ex) {
        Log.e("PercolateAndroidUtils", "Unable to turn on screen for activity " + context);
    }
}

From source file:com.demo.craftscc.core.utils.ActivityUtils.java

public static void setStatusBarColor(Context mContext, int mStatusBarColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = ((Activity) mContext).getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(mContext.getResources().getColor(R.color.bg_gray));
    }/*w w w.  j  a va 2  s .c o  m*/
}

From source file:Main.java

public static void turnScreenOnFlags(Window window) {
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}

From source file:com.microsoft.mimickeralarm.utilities.GeneralUtilities.java

public static void setLockScreenFlags(Window window) {
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}

From source file:Main.java

public static void setFullScreen(Activity activity) {
    activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Window window = activity.getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    window.setAttributes(params);/*from   w ww . j  a  v a  2 s.c o m*/
    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}