Example usage for android.view Display getSize

List of usage examples for android.view Display getSize

Introduction

In this page you can find the example usage for android.view Display getSize.

Prototype

public void getSize(Point outSize) 

Source Link

Document

Gets the size of the display, in pixels.

Usage

From source file:Main.java

public static int screenWidthInPix(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    if (Build.VERSION.SDK_INT >= 13) {
        display.getSize(size);
        return size.x;
    } else {//from ww  w.  jav a 2  s .  co m
        return display.getWidth();
    }

}

From source file:Main.java

public static Point getScreenDisplaySize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point point = new Point();
    if (Build.VERSION.SDK_INT >= 13) {
        display.getSize(point);
    } else {/* w w  w . j  a v a  2  s  .  com*/
        point = new Point(display.getWidth(), display.getHeight());
    }

    return point;
}

From source file:Main.java

public static Point getScreenSize(Context paramContext) {
    Display localDisplay = ((WindowManager) paramContext.getSystemService("window")).getDefaultDisplay();
    Point localPoint = new Point();
    localDisplay.getSize(localPoint);
    return localPoint;
}

From source file:Main.java

public static JsonObject getCustomClientData(final Activity activity) {
    JsonObject data = new JsonObject();

    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenWidth = size.x;
    int screenHeight = size.y;

    data.add("ScreenWidth", new JsonPrimitive(screenWidth));
    data.add("ScreenHeight", new JsonPrimitive(screenHeight));

    JsonObject locale = new JsonObject();
    try {//from w w w  .j  a  va 2s  .  c  o  m
        locale.add("Default", new JsonPrimitive(Locale.getDefault().toString()));
        locale.add("DefaultDisplayLanguage", new JsonPrimitive(Locale.getDefault().getDisplayLanguage()));
        locale.add("DefaultDisplayCountry", new JsonPrimitive(Locale.getDefault().getDisplayCountry()));
        locale.add("DefaultDisplayName", new JsonPrimitive(Locale.getDefault().getDisplayName()));
    } catch (Exception exc) {
    }

    data.add("locale", locale);

    return data;
}

From source file:Main.java

public static Point getWindowSize(Context context) {
    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;//from www .j  a va  2s .  c o m
}

From source file:Main.java

@SuppressLint("NewApi")
public static void getSize(Display display, Point outSize) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        display.getSize(outSize);
    } else {//from   w  ww  . j av a 2 s .  c o m
        outSize.x = display.getWidth();
        outSize.y = display.getHeight();
    }
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point screenResolution = new Point();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        display.getSize(screenResolution);
    } else {//from  ww  w . j a va  2  s.  co m
        screenResolution.set(display.getWidth(), display.getHeight());
    }
    return screenResolution;
}

From source file:Main.java

public static int[] getWindowSize(Context context) {
    final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        Point point = new Point();
        display.getSize(point);
        return new int[] { point.x, point.y };
    } else {/*w  w w  .j a  v a2 s .  c o m*/
        return new int[] { display.getWidth(), display.getHeight() };
    }
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point screenResolution = new Point();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        display.getSize(screenResolution);
    } else {/*from www  . j  ava 2 s . c  o  m*/
        screenResolution.set(display.getWidth(), display.getHeight());
    }

    return screenResolution;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    Display defaultDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay();/* ww w.j  a  va 2s .  c o m*/
    Point point = new Point();
    defaultDisplay.getSize(point);
    return point.x;
}