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 getScreenHeight(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    return display.getHeight();
}

From source file:Main.java

/**
 * Getter for the screen width in pixels.
 *
 * @param context a reference to the context.
 * @return the screen width in pixels./*w w  w. j  a v a 2 s  .c o  m*/
 */
public static int getScreenWidth(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.x;
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point wh = new Point(display.getWidth(), display.getHeight());
    if (wh.x == 0 || wh.y == 0) {
        Log.e("AndroidUtils", "Screen resolution " + wh + " for " + context);
    }// w w  w  . j a  va2s .co  m
    return wh;
}

From source file:Main.java

public static int getScreenWidth(@NonNull Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);/*from www  .j  av a2 s. c  om*/
    return point.x;
}

From source file:Main.java

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

public static Point getAppUsableScreenSize(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from  ww  w .  j a  v a 2 s . c  om
    return size;

}

From source file:Main.java

public static float getScaledWidth(WindowManager windowManager, float baseY, float basex, int exceptDis) {

    final Display display = windowManager.getDefaultDisplay();
    Point mPoint = new Point();
    getSize(display, mPoint);//w ww. j  av a2  s.c o m
    if (exceptDis > mPoint.x) {
        return 0.0f;
    }

    return mPoint.x - exceptDis;
}

From source file:Main.java

public static int getRotation(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();

    return display.getRotation();
}

From source file:Main.java

public static int getWindowWidth(Context context) {
    if (screenSize == null) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        screenSize = new Point();
        display.getSize(screenSize);//w w w .  j a v  a2 s .  c om
    }
    if (screenSize != null)
        return screenSize.x;
    else
        return 0;
}

From source file:Main.java

public static int getWindowHeight(Context context) {
    if (screenSize == null) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        screenSize = new Point();
        display.getSize(screenSize);//from   ww w  .  j av a 2s.c om
    }
    if (screenSize != null)
        return screenSize.y;
    else
        return 0;
}