List of usage examples for android.util DisplayMetrics DENSITY_XHIGH
int DENSITY_XHIGH
To view the source code for android.util DisplayMetrics DENSITY_XHIGH.
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:/* ww w. j a v a 2 s . c o m*/ return 12; } }
From source file:Main.java
/** * Gets device's display density.//ww w.j av a 2s . 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 ww . j a va 2s . c om*/ */ 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 Drawable getIconFromPackageName(String packageName, Context context) { PackageManager pm = context.getPackageManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { try {/*from w ww . 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
public static String getDensity(Context ctx) { String densityStr = null;/* ww w. j ava 2 s .co 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:Main.java
/** * Checks if the device is a tablet or a phone * * @param activityContext/*from w w w .j a v a 2s .c o m*/ * The Activity Context. * @return Returns true if the device is a Tablet */ public static boolean isTabletDevice(Context activityContext) { // Verifies if the Generalized Size of the device is XLARGE to be // considered a Tablet boolean xlarge = ((activityContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE); // If XLarge, checks if the Generalized Density is at least MDPI // (160dpi) if (xlarge) { DisplayMetrics metrics = new DisplayMetrics(); Activity activity = (Activity) activityContext; activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); // MDPI=160, DEFAULT=160, DENSITY_HIGH=240, DENSITY_MEDIUM=160, // DENSITY_TV=213, DENSITY_XHIGH=320 if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM || metrics.densityDpi == DisplayMetrics.DENSITY_TV || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) { // Yes, this is a tablet! return true; } } // No, this is not a tablet! return false; }
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:ch.rts.cordova.is.tablet.IsTablet.java
private boolean isTabletDevice(Context applicationContext) { boolean device_large = ((applicationContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE); if (device_large) { DisplayMetrics metrics = new DisplayMetrics(); Activity activity = this.cordova.getActivity(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM || metrics.densityDpi == DisplayMetrics.DENSITY_TV || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) { Log.d(LOG_TAG, "Is Tablet Device"); return true; }/* www . j a va2 s . c o m*/ } Log.d(LOG_TAG, "Is NOT Tablet Device"); return false; }
From source file:uk.co.workingedge.phonegap.plugin.IsTablet.java
private boolean isTabletDevice(Context applicationContext) { boolean device_large = ((applicationContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE); if (device_large) { DisplayMetrics metrics = new DisplayMetrics(); Activity activity = this.cordova.getActivity(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM || metrics.densityDpi == DisplayMetrics.DENSITY_TV || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH || metrics.densityDpi == DisplayMetrics.DENSITY_XXHIGH) { Log.d(LOG_TAG, "Is Tablet Device"); return true; }/*from ww w . j a v a 2s. c o m*/ } Log.d(LOG_TAG, "Is NOT Tablet Device"); return false; }
From source file:com.iangclifton.auid.appendixc.sections.VariousDemosFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.various_demos, container, false); final StringBuilder sb = new StringBuilder(); // Create a String for the device physical size switch (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) { case Configuration.SCREENLAYOUT_SIZE_XLARGE: // Extra large (most 10" tablets) sb.append(getString(R.string.configuration_xlarge)); break;//from ww w. ja va 2 s . com case Configuration.SCREENLAYOUT_SIZE_LARGE: // Large (most 7" tablets) sb.append(getString(R.string.configuration_large)); break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: // Normal (most phones) sb.append(getString(R.string.configuration_normal)); break; case Configuration.SCREENLAYOUT_SIZE_SMALL: // Small (very uncommon) sb.append(getString(R.string.configuration_small)); break; default: sb.append(getString(R.string.configuration_unknown)); break; } sb.append('\n'); // Create a String for the display density switch (getResources().getDisplayMetrics().densityDpi) { case DisplayMetrics.DENSITY_XXHIGH: // Display is around 480 pixels per inch sb.append(getString(R.string.density_xxhdpi)); break; case DisplayMetrics.DENSITY_XHIGH: // Display is around 320 pixels per inch sb.append(getString(R.string.density_xhdpi)); break; case DisplayMetrics.DENSITY_HIGH: // Display is around 240 pixels per inch sb.append(getString(R.string.density_hdpi)); break; case DisplayMetrics.DENSITY_MEDIUM: // Display is around 160 pixels per inch sb.append(getString(R.string.density_mdpi)); break; case DisplayMetrics.DENSITY_LOW: // Display is around 120 pixels per inch sb.append(getString(R.string.density_ldpi)); break; case DisplayMetrics.DENSITY_TV: // Display is a 720p TV screen // Sometimes also used for 1280x720 7" tablets // Rarely should you ever specifically target this density sb.append(getString(R.string.density_tv)); break; default: sb.append(getString(R.string.density_unknown)); break; } sb.append('\n'); // Create a String for the thread we're on // Obviously this method is always called on the main thread but this technique can be used anywhere. if (Utils.isUiThread()) { // UI Thread sb.append(getString(R.string.main_thread_true)); } else { // Other Thread sb.append(getString(R.string.main_thread_false)); } sb.append(" (Thread name: ").append(Thread.currentThread().getName()).append(')'); // Set text final TextView tv = (TextView) rootView.findViewById(R.id.main_text); tv.setText(sb); return rootView; }