List of usage examples for android.util DisplayMetrics DENSITY_XXXHIGH
int DENSITY_XXXHIGH
To view the source code for android.util DisplayMetrics DENSITY_XXXHIGH.
Click Source Link
From source file:Main.java
public static final float getNormalTextSize(Context context) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_HIGH: return 18; case DisplayMetrics.DENSITY_XHIGH: return 24; case DisplayMetrics.DENSITY_XXHIGH: return 32; case DisplayMetrics.DENSITY_XXXHIGH: return 48; default:/* w ww . j a v a2 s .c om*/ return 12; } }
From source file:Main.java
public static Drawable getIconFromPackageName(String packageName, Context context) { PackageManager pm = context.getPackageManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { try {//w w w. ja v a 2 s. c o m PackageInfo pi = pm.getPackageInfo(packageName, 0); Context otherAppCtx = context.createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY); int displayMetrics[] = { DisplayMetrics.DENSITY_XXXHIGH, DisplayMetrics.DENSITY_XXHIGH, DisplayMetrics.DENSITY_XHIGH, DisplayMetrics.DENSITY_HIGH, DisplayMetrics.DENSITY_MEDIUM, DisplayMetrics.DENSITY_TV }; for (int displayMetric : displayMetrics) { try { Drawable d = otherAppCtx.getResources().getDrawableForDensity(pi.applicationInfo.icon, displayMetric); if (d != null) { return d; } } catch (Resources.NotFoundException e) { } } } catch (Exception e) { // Handle Error here } } ApplicationInfo appInfo = null; try { appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { return null; } return appInfo.loadIcon(pm); }
From source file:Main.java
/** * Gets device's display density.//from ww w . ja v a 2 s. co m * @since 0.1.0 * @param aContext The context from which the display metrics information is retrieved. * @return The density in String or an empty String if display metrics is not retrievable. */ public static String getScreenDpi(Context aContext) { DisplayMetrics metrics = aContext.getResources().getDisplayMetrics(); switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: return "ldpi"; case DisplayMetrics.DENSITY_MEDIUM: return "mdpi"; case DisplayMetrics.DENSITY_HIGH: return "hdpi"; case DisplayMetrics.DENSITY_XHIGH: return "xhdpi"; case DisplayMetrics.DENSITY_XXHIGH: return "xxhdpi"; case DisplayMetrics.DENSITY_XXXHIGH: return "xxxhdpi"; default: return ""; } }
From source file:Main.java
/** * The screen density expressed as dots-per-inch. * @param density_dpi "densityDpi"// w w w . j a v a2s . c o m */ public static String getDensityDPIStr(int density_dpi) { switch (density_dpi) { case DisplayMetrics.DENSITY_LOW://120 return "DENSITY_LOW"; case DisplayMetrics.DENSITY_MEDIUM://160 return "DENSITY_MEDIUM/DENSITY_DEFAULT"; //case DisplayMetrics.DENSITY_DEFAULT://160 // return "DENSITY_DEFAULT"; case DisplayMetrics.DENSITY_TV://213 return "DENSITY_TV"; case DisplayMetrics.DENSITY_HIGH://240 return "DENSITY_HIGH"; case DisplayMetrics.DENSITY_280://280 return "DENSITY_280"; case DisplayMetrics.DENSITY_XHIGH://320 return "DENSITY_XHIGH"; case DisplayMetrics.DENSITY_360://360 return "DENSITY_360"; case DisplayMetrics.DENSITY_400://400 return "DENSITY_400"; case DisplayMetrics.DENSITY_420://420 return "DENSITY_420"; case DisplayMetrics.DENSITY_XXHIGH://480 return "DENSITY_XXHDPI"; case DisplayMetrics.DENSITY_560://560 return "DENSITY_560"; case DisplayMetrics.DENSITY_XXXHIGH://640 return "DENSITY_XXXHDPI"; default: return UNKNOWN; } }
From source file:Main.java
public static String getDensity(Context ctx) { String densityStr = null;/*from w w w . j a va 2s . c o m*/ final int density = ctx.getResources().getDisplayMetrics().densityDpi; switch (density) { case DisplayMetrics.DENSITY_LOW: densityStr = "LDPI"; break; case DisplayMetrics.DENSITY_MEDIUM: densityStr = "MDPI"; break; case DisplayMetrics.DENSITY_TV: densityStr = "TVDPI"; break; case DisplayMetrics.DENSITY_HIGH: densityStr = "HDPI"; break; case DisplayMetrics.DENSITY_XHIGH: densityStr = "XHDPI"; break; case DisplayMetrics.DENSITY_400: densityStr = "XMHDPI"; break; case DisplayMetrics.DENSITY_XXHIGH: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_XXXHIGH: densityStr = "XXXHDPI"; break; } return densityStr; }
From source file:com.mruddy.devdataviewer.DevDataListFragment.java
@SuppressLint("InlinedApi") private static void initMaps() { DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_LOW, "LDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_MEDIUM, "MDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_HIGH, "HDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XHIGH, "XHDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXHIGH, "XXHDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXXHIGH, "XXXHDPI"); DevDataListFragment.ROTATION.append(Surface.ROTATION_0, "0"); DevDataListFragment.ROTATION.append(Surface.ROTATION_90, "90"); DevDataListFragment.ROTATION.append(Surface.ROTATION_180, "180"); DevDataListFragment.ROTATION.append(Surface.ROTATION_270, "270"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_UNDEFINED, "undefined"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_PORTRAIT, "portrait"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_LANDSCAPE, "landscape"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_UNDEFINED, "undefined"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_SMALL, "small"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_NORMAL, "normal"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_LARGE, "large"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_XLARGE, "xlarge"); }
From source file:count.ly.messaging.DeviceInfo.java
/** * Maps the current display density to a string constant. * @param context context to use to retrieve the current display metrics * @return a string constant representing the current display density, or the * empty string if the density is unknown *//*from www . java 2 s .co m*/ static String getDensity(final Context context) { String densityStr = ""; final int density = context.getResources().getDisplayMetrics().densityDpi; switch (density) { case DisplayMetrics.DENSITY_LOW: densityStr = "LDPI"; break; case DisplayMetrics.DENSITY_MEDIUM: densityStr = "MDPI"; break; case DisplayMetrics.DENSITY_TV: densityStr = "TVDPI"; break; case DisplayMetrics.DENSITY_HIGH: densityStr = "HDPI"; break; case DisplayMetrics.DENSITY_XHIGH: densityStr = "XHDPI"; break; case DisplayMetrics.DENSITY_400: densityStr = "XMHDPI"; break; case DisplayMetrics.DENSITY_XXHIGH: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_XXXHIGH: densityStr = "XXXHDPI"; break; } return densityStr; }
From source file:ly.count.android.api.DeviceInfoTests.java
public void testGetDensity() { Context mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_LOW); assertEquals("LDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_MEDIUM); assertEquals("MDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_TV); assertEquals("TVDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_HIGH); assertEquals("HDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XHIGH); assertEquals("XHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXHIGH); assertEquals("XXHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXXHIGH); assertEquals("XXXHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_400); assertEquals("XMHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(0); assertEquals("", DeviceInfo.getDensity(mockContext)); }
From source file:ly.count.android.sdk.DeviceInfo.java
/** * Maps the current display density to a string constant. * @param context context to use to retrieve the current display metrics * @return a string constant representing the current display density, or the * empty string if the density is unknown *//* www . j ava 2s . c o m*/ static String getDensity(final Context context) { String densityStr = ""; final int density = context.getResources().getDisplayMetrics().densityDpi; switch (density) { case DisplayMetrics.DENSITY_LOW: densityStr = "LDPI"; break; case DisplayMetrics.DENSITY_MEDIUM: densityStr = "MDPI"; break; case DisplayMetrics.DENSITY_TV: densityStr = "TVDPI"; break; case DisplayMetrics.DENSITY_HIGH: densityStr = "HDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_260: // densityStr = "XHDPI"; // break; case DisplayMetrics.DENSITY_280: densityStr = "XHDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_300: // densityStr = "XHDPI"; // break; case DisplayMetrics.DENSITY_XHIGH: densityStr = "XHDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_340: // densityStr = "XXHDPI"; // break; case DisplayMetrics.DENSITY_360: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_400: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_420: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_XXHIGH: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_560: densityStr = "XXXHDPI"; break; case DisplayMetrics.DENSITY_XXXHIGH: densityStr = "XXXHDPI"; break; default: densityStr = "other"; break; } return densityStr; }
From source file:com.dm.material.dashboard.candybar.helpers.DrawableHelper.java
@Nullable public static Bitmap getHighQualityIcon(@NonNull Context context, String packageName) { try {// w w w . ja v a 2 s .c o m PackageManager packageManager = context.getPackageManager(); ApplicationInfo info = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA); Resources resources = packageManager.getResourcesForApplication(packageName); int density = DisplayMetrics.DENSITY_XXHIGH; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { density = DisplayMetrics.DENSITY_XXXHIGH; } Drawable drawable = ResourcesCompat.getDrawableForDensity(resources, info.icon, density, null); if (drawable != null) return ((BitmapDrawable) drawable).getBitmap(); } catch (Exception | OutOfMemoryError e) { LogUtil.e(Log.getStackTraceString(e)); } return null; }