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

@TargetApi(Build.VERSION_CODES.KITKAT)
private static void transparentStatusBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {/*  w w  w.j  ava2  s.  c  o m*/
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
}

From source file:org.hawkular.client.android.util.ViewDirector.java

@NonNull
public static ViewDirector of(@NonNull Activity activity) {
    return new ViewDirector(activity.getWindow().getDecorView());
}

From source file:Main.java

public static int getStatusBarHeight(Activity context) {
    int statusHeight = 0;
    Rect frame = new Rect();
    context.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    statusHeight = frame.top;/*from ww w  .j a  v a  2  s.  co m*/
    if (0 == statusHeight) {
        Class<?> localClass;
        try {
            localClass = Class.forName("com.android.internal.R$dimen");
            Object localObject = localClass.newInstance();
            int i5 = Integer.parseInt(localClass.getField("status_bar_height").get(localObject).toString());
            statusHeight = context.getResources().getDimensionPixelSize(i5);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return statusHeight;
}

From source file:Main.java

/**
 * Removes the action bar from the activity. This only works on API 11+.
 *
 * @param activity/*  w w w . j a v  a2  s. co  m*/
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void removeActionBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
        activity.getActionBar().hide();
    }
}

From source file:jahirfiquitiva.iconshowcase.utilities.utils.ThemeUtils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void onActivityCreateSetNavBar(Activity activity) {
    activity.getWindow().setNavigationBarColor(
            darkTheme ? ContextCompat.getColor(activity, R.color.dark_theme_navigation_bar)
                    : ContextCompat.getColor(activity, R.color.light_theme_navigation_bar));
}

From source file:Main.java

public static void setActivityWindowAlpha(Activity activity, float alpha) {
    // TODO Auto-generated method stub
    WindowManager.LayoutParams params = activity.getWindow().getAttributes();
    params.alpha = alpha;// w ww  .  j  a  v a2s.c om
    activity.getWindow().setAttributes(params);
}

From source file:Main.java

private static void setTranslucentStatus(Activity context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window win = context.getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        winParams.flags |= bits;/*from   w w  w.j  a v  a2s  .  c  o  m*/
        win.setAttributes(winParams);
    }

}

From source file:Main.java

public static void openImmerseStatasBarMode(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = activity.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }//from   w  ww . jav a 2 s .  c om
}

From source file:Main.java

private static void transparentStatusBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {// w w  w.j  a v  a2s.c om
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
}

From source file:Main.java

public static Bitmap takeScreenshot(Activity activity, int ResourceID) {
    View view = activity.getWindow().getDecorView().findViewById(ResourceID);
    return takeScreenshot(activity, view);
}