Example usage for android.app Activity getWindowManager

List of usage examples for android.app Activity getWindowManager

Introduction

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

Prototype

public WindowManager getWindowManager() 

Source Link

Document

Retrieve the window manager for showing custom windows.

Usage

From source file:Main.java

public static int getDisplayHeight(Activity mactivity) {
    return mactivity.getWindowManager().getDefaultDisplay().getHeight();
}

From source file:Main.java

public static int getScreenWidth(Activity activity) {
    WindowManager manager = activity.getWindowManager();
    Display display = manager.getDefaultDisplay();
    return display.getWidth();
}

From source file:Main.java

public static int getScreenHeight(Activity activity) {
    WindowManager manager = activity.getWindowManager();
    Display display = manager.getDefaultDisplay();
    return display.getHeight();
}

From source file:Main.java

private static int getDisplayHeight(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    return display.getHeight();
}

From source file:Main.java

@SuppressWarnings("deprecation")
private static int[] getScreenParams(Activity mContext) {

    WindowManager wm = mContext.getWindowManager();

    int width = wm.getDefaultDisplay().getWidth();
    int height = wm.getDefaultDisplay().getHeight();

    return new int[] { width, height };
}

From source file:Main.java

public static int getDpi(Activity activity) {
    WindowManager wm = activity.getWindowManager();
    //wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    Display dp = wm.getDefaultDisplay();
    DisplayMetrics dm = new DisplayMetrics();
    dp.getMetrics(dm);/*from w ww  . j ava  2 s. c  o  m*/
    return dm.densityDpi;
}

From source file:Main.java

public static Point getScreenSize(@Nullable Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);/*from w  w  w . ja va 2  s .  com*/
    return point;
}

From source file:Main.java

public static int getRotationAngle(Activity activity) {
    switch (activity.getWindowManager().getDefaultDisplay().getRotation()) {
    default:/*  w ww .j  av  a 2 s.  c  om*/
        return 0;
    }
}

From source file:Main.java

public static Point getDisplaySize(Activity context) {
    Display display = context.getWindowManager().getDefaultDisplay();
    final Point point = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        display.getSize(point);//from  w w w . ja v a 2s .c om
    } else {
        point.x = display.getWidth();
        point.y = display.getHeight();
    }
    return point;
}

From source file:Main.java

public static boolean isLandscapeMode(Activity activity) {
    Display d = activity.getWindowManager().getDefaultDisplay();
    if (d.getWidth() > d.getHeight())
        return true;
    else/*  w  w w .  j a  v  a 2s.  c  o  m*/
        return false;
}