Example usage for android.view WindowManager getDefaultDisplay

List of usage examples for android.view WindowManager getDefaultDisplay

Introduction

In this page you can find the example usage for android.view WindowManager getDefaultDisplay.

Prototype

public Display getDefaultDisplay();

Source Link

Document

Returns the Display upon which this WindowManager instance will create new windows.

Usage

From source file:Main.java

public static int getDeviceWidth(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return manager.getDefaultDisplay().getWidth();
}

From source file:Main.java

public static int getDeviceHeight(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return manager.getDefaultDisplay().getHeight();
}

From source file:Main.java

/**
 * Get the constant describing the rotation of the screen.
 *
 * @param context//from  w  w w.j  av a  2  s  . c  om
 * @return
 */
public static int getDisplayRotation(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return wm.getDefaultDisplay().getRotation();
}

From source file:Main.java

public static float getDensity(Context context) {
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager wm = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE));
    wm.getDefaultDisplay().getMetrics(metrics);

    return metrics.density;
}

From source file:Main.java

public static int screenWitdh(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int width = wm.getDefaultDisplay().getWidth();
    return width;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int width = wm.getDefaultDisplay().getWidth();
    return width;
}

From source file:Main.java

public static float getDensity(Context context) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.density;
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static int getDeviceWidth(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return manager.getDefaultDisplay().getWidth();
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static int getDeviceHeight(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return manager.getDefaultDisplay().getHeight();
}

From source file:Main.java

/**
 * This method to get screen size./*from ww  w . j  av a 2s . c o m*/
 * 
 * @param context
 * @return window manager instance which contains width and height of the
 *         screen
 */
public static DisplayMetrics getScreenSize(Context context) {
    // TODO Auto-generated method stub
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(dm);
    return dm;
}