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 calculateImageSize(WindowManager window, int divider) {
    Display display = window.getDefaultDisplay();
    Point resolution = new Point();
    display.getSize(resolution);//from   w  w w .  j a  va2  s . co m
    int width = resolution.x / divider;
    int height = resolution.y / divider;

    return Math.min(width, height);
}

From source file:Main.java

@SuppressLint("SwitchIntDef")
public static int getRotationOffset(@NonNull WindowManager windowManager) {
    switch (windowManager.getDefaultDisplay().getRotation()) {
    case Surface.ROTATION_90:
        return 90;
    case Surface.ROTATION_180:
        return 180;
    case Surface.ROTATION_270:
        return 270;
    default:/*from w  w  w.  ja va  2  s  .  co m*/
        return 0;
    }
}

From source file:Main.java

@SuppressWarnings("deprecation")
private static int[] getScreenParams(Activity mContext) {

    WindowManager wm = mContext.getWindowManager();

    int width = wm.getDefaultDisplay().getWidth();
    int height = wm.getDefaultDisplay().getHeight();

    return new int[] { width, height };
}

From source file:Main.java

public static int getScreenWidth(Activity activity) {
    WindowManager manager = activity.getWindowManager();
    Display display = manager.getDefaultDisplay();
    return display.getWidth();
}

From source file:Main.java

public static int getScreenHeight(Activity activity) {
    WindowManager manager = activity.getWindowManager();
    Display display = manager.getDefaultDisplay();
    return display.getHeight();
}

From source file:Main.java

public static int getScreenHeight(Context act) {
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) act.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.heightPixels;
}

From source file:Main.java

public static String getScreenSize(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(dm);
    return dm.widthPixels + "x" + dm.heightPixels;
}

From source file:Main.java

public static DisplayMetrics getScreenDisplayMetrics(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(dm);
    return dm;// w w w.  j  a v  a  2  s .  c o m
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(metrics);
    return metrics.widthPixels;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.widthPixels;
}