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 getScreenOrientation(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (display.getWidth() == display.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {/*from ww w. j a v a 2s . c o m*/ if (display.getWidth() < display.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
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 getScreenWidth(Context context) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); manager.getDefaultDisplay().getMetrics(metrics); return metrics.widthPixels; }
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 int getScreenHeight(Context context) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); manager.getDefaultDisplay().getMetrics(metrics); return metrics.heightPixels; }
From source file:Main.java
public static int getScreenHeight(Context act) { final DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) act.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.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; }
From source file:Main.java
public static DisplayMetrics getScreenDisplayMetrics(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); return dm;/*from w w w.j a v a2 s . c o m*/ }
From source file:Main.java
public static float getDensity(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.density; }
From source file:Main.java
public static int getScreenWidth(Context act) { final DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) act.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.widthPixels; }