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 int getWindowHeight(Activity activity) {
    Rect out = new Rect();
    activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getHitRect(out);
    return out.height();
}

From source file:Main.java

public static void closeKeyboard(Activity activity) {
    View view = activity.getWindow().peekDecorView();
    if (view != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }/* w  ww. ja  v a  2s . co  m*/
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static void hideSoftInput(Activity activity) {
    View view = activity.getWindow().peekDecorView();
    if (view != null) {
        InputMethodManager inputmanger = (InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }//from   w  w w .j  a  v  a  2 s  .  com
}

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 Rect getStatusBarInfo(Activity context) {
    Rect frame = new Rect();
    context.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    return frame;
}

From source file:Main.java

public static float getScreenBrightness(Activity activity) {
    WindowManager.LayoutParams lpa = activity.getWindow().getAttributes();

    return lpa.screenBrightness;
}

From source file:Main.java

public static Window getWindow(@NonNull final Activity activity) {
    return activity.getWindow();
}

From source file:Main.java

public static Bitmap getScreenViewBitmap(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);//from  ww w.j  a  v  a 2 s  . c  om
    view.buildDrawingCache();
    Bitmap bitmap = view.getDrawingCache();
    return bitmap;
}

From source file:Main.java

public static float getActivityBrightness(Activity activity) {
    WindowManager.LayoutParams params = activity.getWindow().getAttributes();
    return params.screenBrightness;
}

From source file:Main.java

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