Example usage for android.app Activity getWindow

List of usage examples for android.app Activity getWindow

Introduction

In this page you can find the example usage for android.app Activity getWindow.

Prototype

public Window getWindow() 

Source Link

Document

Retrieve the current android.view.Window for the activity.

Usage

From source file:Main.java

/**
 * /*  ww w  .j  av a  2s. c  om*/
 * @param activity
 */
public static void quitFullScreen(Activity activity) {
    final WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
    attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
    activity.getWindow().setAttributes(attrs);
    activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

From source file:Main.java

@TargetApi(19)
public static void setUIVisibility(Activity activity) {
    View decorView = activity.getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    if (Build.VERSION.SDK_INT >= 16) {
        uiOptions = uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN;
    }/* w w  w.ja  v a  2  s .com*/
    if (Build.VERSION.SDK_INT >= 19) {
        uiOptions = uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    decorView.setSystemUiVisibility(uiOptions);
}

From source file:Main.java

public static Bitmap snapShotWithStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);/*from ww  w . j  a  v a2s .c  o m*/
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    int width = getScreenWidth(activity);
    int height = getScreenHeight(activity);
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
    view.destroyDrawingCache();
    return bp;

}

From source file:Main.java

public static int getStatusBarHeight(Activity activity) {
    Rect outRect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
    return outRect.top;
}

From source file:Main.java

/**
 * Take screenshot of the activity including the action bar
 * /* ww w . j a  v  a 2 s.c  om*/
 * @param activity
 * @return The screenshot of the activity including the action bar
 */
public static Bitmap takeScreenshot(Activity activity) {
    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setDrawingCacheEnabled(true);
    decorChild.buildDrawingCache();
    Bitmap drawingCache = decorChild.getDrawingCache(true);
    Bitmap bitmap = Bitmap.createBitmap(drawingCache);
    decorChild.setDrawingCacheEnabled(false);
    return bitmap;
}

From source file:Main.java

public static Bitmap snapShotWithStatusBar(Activity activity) {
    View decorView = activity.getWindow().getDecorView();
    decorView.setDrawingCacheEnabled(true);
    decorView.buildDrawingCache();/*  ww w . j  av  a2s. c om*/
    Bitmap bmp = decorView.getDrawingCache();
    int width = getScreenWidth(activity);
    int height = getScreenHeight(activity);
    Bitmap bitMap = null;
    bitMap = Bitmap.createBitmap(bmp, 0, 0, width, height);
    decorView.destroyDrawingCache();
    return bitMap;
}

From source file:Main.java

public static void showStatusBar(Activity activity) {
    WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
    attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
    activity.getWindow().setAttributes(attrs);
}

From source file:Main.java

public static void hideStatusBar(Activity activity) {
    WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
    attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    activity.getWindow().setAttributes(attrs);
}

From source file:Main.java

public static void setWakeLock(Activity activity, boolean wakeLock) {
    if (wakeLock) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {//  w  ww  . jav a2s. c om
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}

From source file:Main.java

public static void setActBrightness(Activity activity, int brightness) {
    WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
    lp.screenBrightness = brightness / (float) MAX_BRIGHTNESS;
    activity.getWindow().setAttributes(lp);
}