ulfben

Android get screen density name (bucket)

Jan 25th, 2017
429
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //https://developer.android.com/about/dashboards/index.html#Screens
  2. private static String getDensityName(DisplayMetrics dm) {
  3.         float density = dm.density;
  4.         if (density >= 4.0) {
  5.             return "xxxhigh density";
  6.         }
  7.         if (density >= 3.0) {
  8.             return "xxhigh density";
  9.         }
  10.         if (density >= 2.0) {
  11.             return "xhigh density";
  12.         }
  13.         if (density >= 1.5) {
  14.             return "high density";
  15.         }
  16.         if (density >= 1.0) {
  17.             return "medium density";
  18.         }
  19.         return "low density";
  20.     }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×