List of usage examples for android.content.res Resources getSystem
public static Resources getSystem()
From source file:Main.java
public static int[] getScreenSize(Context context) { DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); int width = metrics.widthPixels; int height = metrics.heightPixels; int[] screen = { width, height }; return screen; }
From source file:Main.java
public static int getPxFromDP(int dp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, Resources.getSystem().getDisplayMetrics()); }
From source file:Main.java
public static int getDementions(int value) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, Resources.getSystem().getDisplayMetrics()); }
From source file:Main.java
/** * to get the screen's density//from w w w . jav a 2 s.c o m * * @return */ public static float getDeviceDensity() { return Resources.getSystem().getDisplayMetrics().density; }
From source file:Main.java
/** * to get the screen's width (pixels)/* w w w.j a v a2s .c om*/ * * @return */ public static int getScreeWidth() { return Resources.getSystem().getDisplayMetrics().widthPixels; }
From source file:Main.java
/** * to get the screen's height (pixels)//ww w . j a v a 2 s . com * * @return */ public static int getScreeHeight() { return Resources.getSystem().getDisplayMetrics().heightPixels; }
From source file:Main.java
public static int dpToPx(Double dp) { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); }
From source file:Main.java
public static int getMaximumScreenBrightnessSetting(Context context) { final Resources res = Resources.getSystem(); final int id = res.getIdentifier("config_screenBrightnessSettingMaximum", "integer", "android"); // API17+ if (id != 0) { try {//from ww w . ja va 2 s. c o m return res.getInteger(id); } catch (Resources.NotFoundException e) { // ignore } } return 255; }
From source file:Main.java
public static int getMinimumScreenBrightnessSetting(Context context) { final Resources res = Resources.getSystem(); int id = res.getIdentifier("config_screenBrightnessSettingMinimum", "integer", "android"); // API17+ if (id == 0)// w w w . j a v a 2 s . c o m id = res.getIdentifier("config_screenBrightnessDim", "integer", "android"); // lower API levels if (id != 0) { try { return res.getInteger(id); } catch (Resources.NotFoundException e) { // ignore } } return 0; }
From source file:Main.java
static int sp2px(int sp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, Resources.getSystem().getDisplayMetrics()); }