Code for obtaining screen size in Android

From , 3 Years ago, written in Java, viewed 203 times.
URL https://pastebin.vip/view/1299c1b7
  1.   public static String getDisplayMetrics(Context cx) {
  2.                 String str = "";
  3.                 DisplayMetrics dm = new DisplayMetrics();
  4.                 dm = cx.getApplicationContext().getResources().getDisplayMetrics();
  5.                 int screenWidth = dm.widthPixels;
  6.                 int screenHeight = dm.heightPixels;
  7.                 float density = dm.density;
  8.                 float xdpi = dm.xdpi;
  9.                 float ydpi = dm.ydpi;
  10.                 str += "The absolute width:" + String.valueOf(screenWidth) + "pixels\n";
  11.                 str += "The absolute heightin:" + String.valueOf(screenHeight)
  12.                                 + "pixels\n";
  13.                 str += "The logical density of the display.:" + String.valueOf(density)
  14.                                 + "\n";
  15.                 str += "X dimension :" + String.valueOf(xdpi) + "pixels per inch\n";
  16.                 str += "Y dimension :" + String.valueOf(ydpi) + "pixels per inch\n";
  17.                 return str;
  18.         }
  19. //java/6369

Reply to "Code for obtaining screen size in Android"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website