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 DisplayMetrics getScreenSizeInPx(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);/*from  w  w w  . ja va  2 s . c om*/
    return metrics;
}

From source file:Main.java

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

From source file:Main.java

public static int getScreenWidth(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);//from ww  w  .j av a2 s.  co  m

    return metrics.widthPixels;
}

From source file:Main.java

private static void getScreenMetric(Context cxt) {
    WindowManager wm = (WindowManager) cxt.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from w  w w  . ja  v  a  2 s.  c om
    mScreenWidth = size.x;
    mScreenHeight = size.y;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static DisplayMetrics getScreenSize(Context context) {
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    display.getMetrics(metrics);/*from   www.  j  a va  2 s .c om*/
    return metrics;
}

From source file:Main.java

public static int[] getScreenSize(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();

    return new int[] { display.getWidth(), display.getHeight() };
}

From source file:Main.java

public static Point getDisplaySize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*from ww  w.  jav a  2 s. c  om*/
    int width = size.x;
    int height = size.y;
    return new Point(width, height);
}

From source file:Main.java

public static int getScreenMinWidth(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from w  w w .  j a v  a 2 s.  co m
    return Math.min(size.x, size.y);
}