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

/**
 * Gets the available width using only the DisplayMetrics class and removing known decorations.
 *//*from   www.ja va  2  s  .c  om*/
@SuppressWarnings("deprecation")
public static int getDisplayWidth(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    return display.getWidth();
}

From source file:Main.java

public static int getScreenWidth(Activity activity) {
    WindowManager manager = activity.getWindowManager();
    DisplayMetrics outMetrics = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(outMetrics);
    //        int height = outMetrics.heightPixels;
    int width2 = outMetrics.widthPixels;
    return width2;
}

From source file:Main.java

public static int GetScreenHeight(Activity act) {
    DisplayMetrics dm = new DisplayMetrics();
    act.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm.heightPixels;
}

From source file:Main.java

public static void setScannerWidth(Activity ac) {
    DisplayMetrics dm = new DisplayMetrics();
    ac.getWindowManager().getDefaultDisplay().getMetrics(dm);
    SCANNER_WIDT = dm.widthPixels;/*from w  ww. j  a v a 2s  .  co  m*/
}

From source file:Main.java

public static float getDensity(Activity act) {
    DisplayMetrics dm = new DisplayMetrics();
    act.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm.density;
}

From source file:Main.java

/**
 * Determining the smallest size of the screen to detect "real small devices",
 * the dpi modifier is not reliable on Samsung devices
 *
 * @param activity - current activity/*from  ww w . j a  v  a  2 s.  com*/
 * @return the size of the smallest edge of default display in pixels
 */
private static int getSmallestScreenSize(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    return Math.min(point.x, point.y);
}

From source file:Main.java

public static int getScreenWidth(Activity act) {
    DisplayMetrics dm = new DisplayMetrics();
    act.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm.widthPixels;
}

From source file:Main.java

public static int getScreenHight(Activity activity) {
    WindowManager manager = activity.getWindowManager();
    DisplayMetrics outMetrics = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(outMetrics);
    int height = outMetrics.heightPixels;
    //int width2 = outMetrics.widthPixels;
    return height;
}

From source file:Main.java

public static int getScreenHeight(Activity act) {
    DisplayMetrics dm = new DisplayMetrics();
    act.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm.heightPixels;
}

From source file:Main.java

public static DisplayMetrics screenSize(Activity c) {
    DisplayMetrics dm = new DisplayMetrics();
    c.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm;//from  ww  w.  ja v  a  2  s . c  om
}