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 getScreenHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w ww. j a va 2s .co m return size.y; }
From source file:Main.java
public static Point getScreenSize(Context applicationContext) { WindowManager wm = (WindowManager) applicationContext.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 www.j av a 2 s . c o m else { size.x = display.getWidth(); size.y = display.getHeight(); } return size; }
From source file:Main.java
/** * @param context//from ww w .jav a 2 s . c o m * @param height * @return */ public static int getMetricsDensity(Context context, float height) { DisplayMetrics localDisplayMetrics = new DisplayMetrics(); ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() .getMetrics(localDisplayMetrics); return Math.round(height * localDisplayMetrics.densityDpi / 160.0F); }
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 int getScreenHeight(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); return display.getHeight(); }
From source file:Main.java
public static float getDisplayDensity(Context context) { if (sDensity == Float.MAX_VALUE) { Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay();//from w w w .j a v a2 s .com DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); sDensity = metrics.density; } return sDensity; }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point);/* ww w. j a va2 s.c om*/ return point.x; }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point);//from w w w.j a va2 s . c o m return point.y; }
From source file:Main.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") public static int getWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); display.getSize(size);/*from www . ja v a2 s. c om*/ return size.x; } else return display.getWidth(); }
From source file:Main.java
@SuppressWarnings("deprecation") /**/*from w ww. j a v a 2 s .co m*/ * Returns the screen/display size * * @param ctx * @return */ public static Point getDisplaySize(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); return new Point(width, height); }