List of usage examples for android.view WindowManager getDefaultDisplay
public Display getDefaultDisplay();
From source file:Main.java
public static int getOrientation(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display getOrient = windowManager.getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (getOrient.getWidth() == getOrient.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {/*w ww . j a va2s . c o m*/ if (getOrient.getWidth() < getOrient.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
From source file:Main.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") // Whole Screen includes StatusBar and ActionBar public static int getHeight(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 w w w . j a v a2 s . c o m*/ return size.y; } else return display.getHeight(); }
From source file:Main.java
public static Point libgdxToScreenCoordinates(Context context, float x, float y) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w w w . j a va2 s .c o m // Log.d(CucumberInstrumentation.TAG, String.format("center: [%d/%d]", size.x / 2, size.y / 2)); Point point = new Point(); point.x = Math.round((size.x / 2f) + x); point.y = Math.round((size.y / 2f) + y); // Log.d(CucumberInstrumentation.TAG, String.format("coords: [%d/%d]", point.x, point.y)); return point; }
From source file:Main.java
public static int getWindowWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metric = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metric); return metric.widthPixels; }
From source file:Main.java
public static DisplayMetrics dueDisplayMetrics(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm;//from ww w. j a v a2s .c o m }
From source file:Main.java
public static int getScreenWidth(Context mContext) { WindowManager manager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; }
From source file:Main.java
public static int getWindowWidth(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; }
From source file:Main.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") public static int[] getScreenWidthHeight(Context context) { int[] widthAndHeight = new int[2]; WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT >= 13) { Point size = new Point(); display.getSize(size);/*from ww w. ja v a 2s .c o m*/ widthAndHeight[0] = size.x; widthAndHeight[1] = size.y; } else { widthAndHeight[0] = display.getWidth(); widthAndHeight[1] = display.getHeight(); } return widthAndHeight; }
From source file:Main.java
public static int getWindowHeight(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); return dm.heightPixels; }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); return metrics.heightPixels; }