List of usage examples for android.app Activity getWindowManager
public WindowManager getWindowManager()
From source file:Main.java
/** * Get the required size of the favicon, depending on current screen density. * @param activity The current activity. * @return The size of the favicon, in pixels. *//*from www. j a v a2 s . co m*/ public static int getFaviconSize(Activity activity) { if (mFaviconSize == -1) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: mFaviconSize = 12; break; case DisplayMetrics.DENSITY_MEDIUM: mFaviconSize = 24; break; case DisplayMetrics.DENSITY_HIGH: mFaviconSize = 32; break; default: mFaviconSize = 24; } } return mFaviconSize; }
From source file:com.activiti.android.ui.utils.DisplayUtils.java
public static int getWidth(Activity context) { Display display = context.getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics);//ww w.j ava 2 s. c o m float density = context.getResources().getDisplayMetrics().density; int width = Math.round(outMetrics.widthPixels / density); Resources res = context.getResources(); int coeff = 150; return coeff; }
From source file:Main.java
public static void getDensity(Activity activity) { if (DEVICE_DENSITY == 0) { DisplayMetrics metrics = new DisplayMetrics(); float density = metrics.density; activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); DEVICE_DENSITY = metrics.density; }//from w w w .j a v a 2s. co m }
From source file:com.arlib.floatingsearchview.util.Util.java
public static int getScreenWidth(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics);//from w ww. j a v a 2 s . co m return outMetrics.widthPixels; }
From source file:Main.java
public static DisplayMetrics getDisplayMetrics(Activity context) { DisplayMetrics displayMetrics = null; if (displayMetrics == null) { displayMetrics = new DisplayMetrics(); }//from w ww .j av a2 s . c om context.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics; }
From source file:Main.java
public static int[] getRealScreenSize(Activity activity) { int[] size = new int[2]; int screenWidth = 0, screenHeight = 0; WindowManager w = activity.getWindowManager(); Display d = w.getDefaultDisplay();// ww w. jav a2 s. com DisplayMetrics metrics = new DisplayMetrics(); d.getMetrics(metrics); // since SDK_INT = 1; screenWidth = metrics.widthPixels; screenHeight = metrics.heightPixels; // includes window decorations (statusbar bar/menu bar) if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) try { screenWidth = (Integer) Display.class.getMethod("getRawWidth").invoke(d); screenHeight = (Integer) Display.class.getMethod("getRawHeight").invoke(d); } catch (Exception ignored) { } // includes window decorations (statusbar bar/menu bar) if (Build.VERSION.SDK_INT >= 17) try { Point realSize = new Point(); Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize); screenWidth = realSize.x; screenHeight = realSize.y; } catch (Exception ignored) { } size[0] = screenWidth; size[1] = screenHeight; return size; }
From source file:Main.java
public static DisplayMetrics getDisplayMetrics(Activity activity) { DisplayMetrics displayMetrics = null; if (density == -1) { displayMetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); }// ww w . j a v a 2 s .co m return displayMetrics; }
From source file:Main.java
@SuppressLint("NewApi") public static float[] getRealWH(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics); int height = metrics.heightPixels; int width = metrics.widthPixels; float[] wh = { width, height }; return wh; }//www . ja va2 s . c o m float[] aa = { 0, 0 }; return aa; }
From source file:Main.java
/** * Get the required size of the favicon, depending on current screen density. * @param activity The current activity. * @return The size of the favicon, in pixels. *//*from w w w . j a va 2 s .c o m*/ public static int getFaviconSizeForBookmarks(Activity activity) { if (mFaviconSizeForBookmarks == -1) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: mFaviconSizeForBookmarks = 12; break; case DisplayMetrics.DENSITY_MEDIUM: mFaviconSizeForBookmarks = 16; break; case DisplayMetrics.DENSITY_HIGH: mFaviconSizeForBookmarks = 24; break; default: mFaviconSizeForBookmarks = 16; } } return mFaviconSizeForBookmarks; }
From source file:Main.java
public static int[] getScreenSize(Activity activity) { int[] screens; // if (Constants.screenWidth > 0) { // return screens; // }//w w w . j a va 2s .c om DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); screens = new int[] { dm.widthPixels, dm.heightPixels }; return screens; }