List of usage examples for android.view WindowManager getDefaultDisplay
public Display getDefaultDisplay();
From source file:Main.java
public static float getDeviceDensity(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 getScreeWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay().getWidth(); }
From source file:Main.java
public static int getScreenHeight(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.heightPixels; }
From source file:Main.java
public static int getDisplayWidth(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.widthPixels; }
From source file:Main.java
public static double getDeviceXDPI(Context context) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager mgr = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mgr.getDefaultDisplay().getMetrics(metrics); return metrics.xdpi; }
From source file:Main.java
public static int getDeviceDPI(Context context) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager mgr = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mgr.getDefaultDisplay().getMetrics(metrics); return metrics.densityDpi; }
From source file:Main.java
public static int GetScreenWidth(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay().getHeight(); }
From source file:Main.java
public static int[] getDisplayResolutionWH(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); return new int[] { dm.widthPixels, dm.heightPixels }; }
From source file:Main.java
public static int getDisplayHeight(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.heightPixels; }