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

public static void setWindowAlpha(Activity activity, float alpha) {
    LayoutParams params = activity.getWindow().getAttributes();
    // params.alpha = alpha;
    params.screenBrightness = alpha;//from  w  w w . j av  a2s.  com
    activity.getWindow().setAttributes(params);
}

From source file:Main.java

/**
 * getContentView from an activity//from  ww w.j a  va 2  s .  c o  m
 * @param activity
 * @return View
 */
public static View getContentView(Activity activity) {
    ViewGroup view = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup content = (ViewGroup) view.findViewById(android.R.id.content);
    return content.getChildAt(0);
}

From source file:Main.java

public static boolean isStatusBarExists(Activity activity) {
    WindowManager.LayoutParams params = activity.getWindow().getAttributes();
    return (params.flags
            & WindowManager.LayoutParams.FLAG_FULLSCREEN) != WindowManager.LayoutParams.FLAG_FULLSCREEN;
}

From source file:Main.java

public static Bitmap snapShotWithStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);/*from w  w w.j  a v  a  2s. c  om*/
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    int[] screen = getWidthAndHeight(activity);
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, 0, screen[0], screen[1]);
    view.destroyDrawingCache();
    return bp;

}

From source file:Main.java

public static LinearLayout fetchAppLayout(Activity activity) {
    FrameLayout rootView = (FrameLayout) activity.getWindow().getDecorView().getRootView();
    LinearLayout rootLayout = (LinearLayout) rootView.getChildAt(0);
    return ((LinearLayout) ((FrameLayout) rootLayout.getChildAt(1)).getChildAt(0));
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static int getStatusBarHeight(Activity activity) {
    Rect frame = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    return frame.top;
}

From source file:Main.java

public static void setFullScreen(Activity activity) {
    WindowManager.LayoutParams params = activity.getWindow().getAttributes();
    params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    activity.getWindow().setAttributes(params);
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

From source file:Main.java

public static void quitFullScreen(Activity act) {
    final WindowManager.LayoutParams attrs = act.getWindow().getAttributes();
    attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
    act.getWindow().setAttributes(attrs);
    act.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

From source file:Main.java

public static void cancelFullScreen(Activity activity) {
    WindowManager.LayoutParams params = activity.getWindow().getAttributes();
    params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
    activity.getWindow().setAttributes(params);
    activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

From source file:Main.java

public static boolean isTranslucencyAllowed(Activity activity) {
    WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
    int i = lp.flags;
    boolean fullScreen = (i & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
    boolean forceNotFullScreen = (i & WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN) != 0;
    boolean translucentStatus = (i & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) != 0;
    return (!fullScreen || forceNotFullScreen && !translucentStatus);
}