1

I'm calculating the screen width (in inches) like this:

DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
float wInches = dm.widthPixels / dm.xdpi;

This usually works fine. However, I noticed that on Nexus 4 (Android 4.4.4) xdpi==159.895

I saw in this post that he mentions other devices that return wrong values, but in his table Nexus 4 returns the right measure.

  • Did anyone else notice this behavior?
  • Is there a safe and accurate way of calculating the exact screen size?
Community
  • 1
  • 1
grebulon
  • 7,697
  • 5
  • 42
  • 66

0 Answers0