List of usage examples for android.content Context WINDOW_SERVICE
String WINDOW_SERVICE
To view the source code for android.content Context WINDOW_SERVICE.
Click Source Link
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);// ww w. j a va2s. c om return size.x; }
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);//from w w w .j av a2s . c o m return size; }
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);//from w ww. j ava2s.c o m } else { point = new Point(display.getWidth(), display.getHeight()); } return point; }
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(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size);/*from w ww .j av a2 s .c om*/ } else { size.set(display.getWidth(), display.getHeight()); } return size; }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); manager.getDefaultDisplay().getMetrics(metric); return metric.widthPixels; }
From source file:Main.java
public static int dp2px(Context context, int dp) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics displaymetrics = new DisplayMetrics(); display.getMetrics(displaymetrics);/* ww w .jav a2 s . c o m*/ return (int) (dp * displaymetrics.density + 0.5f); }
From source file:Main.java
public static float getScreenDPI(Context context) { final DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return (float) displayMetrics.densityDpi; }
From source file:Main.java
public static int getScreenMinWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);//ww w .j av a2 s . c o m return Math.min(size.x, size.y); }
From source file:Main.java
public static int getDeviceWidth(Context context) { int width = 0; DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); width = dm.widthPixels;//from w ww .j a v a 2 s . c o m return width; }
From source file:Main.java
public static int getScreenWidth(Context context) { Display defaultDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay();// w w w. j ava 2s . c o m Point point = new Point(); defaultDisplay.getSize(point); return point.x; }