List of usage examples for android.view WindowManager getDefaultDisplay
public Display getDefaultDisplay();
From source file:Main.java
public static void init(Context context) { if (context == null) { return;//from w w w .j a va 2 s . c om } DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); SCREEN_WIDTH_PIXELS = dm.widthPixels; SCREEN_HEIGHT_PIXELS = dm.heightPixels; SCREEN_DENSITY = dm.density; SCREEN_WIDTH_DP = (int) (SCREEN_WIDTH_PIXELS / dm.density); SCREEN_HEIGHT_DP = (int) (SCREEN_HEIGHT_PIXELS / dm.density); }
From source file:Main.java
/** * Get device's resolution size//from www . j av a2 s .com * @param context {@link Context} * @return {@link Display} : device resolution size as display */ public static Display getResolutionSize(Context context) throws Exception { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); return display; }
From source file:Main.java
public static Point getScreenSize(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*w w w . j a va2 s .co m*/ return size; }
From source file:Main.java
public static int getWindowHeight(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); return display.getHeight(); }
From source file:Main.java
public static int getWindowWidth(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[] getScreenPixels(Context context) { DisplayMetrics displaysMetrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); windowManager.getDefaultDisplay().getMetrics(displaysMetrics); int[] widthAndHeight = new int[2]; widthAndHeight[0] = displaysMetrics.widthPixels; widthAndHeight[1] = displaysMetrics.heightPixels; return widthAndHeight; }
From source file:Main.java
private static float getDefaultDisplayRefreshRate(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return manager.getDefaultDisplay().getRefreshRate(); }
From source file:Main.java
public static int getScreenWidth(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); display.getMetrics(dm);// w w w. jav a2s . c o m return dm.widthPixels; }
From source file:Main.java
public static int getDisplayWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/* w ww . j a v a 2 s .c o m*/ return size.x; }
From source file:Main.java
public static int getScreenHeight(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); display.getMetrics(dm);/*from ww w . j a va2 s. c o m*/ return dm.heightPixels; }