We've noticed a data anomaly recently in that a number of devices are misreporting their xdpi and ydpi via DisplayMetrics.
As a specific example, all SPH-L710 Sprint Galaxy S III devices running 4.4.2 are reporting an xdpi and ydpi of ~160. With a resolution of 1280x720, this would measure out to a ~9 inch screen size which is obviously not the case. Prior to 4.4.2, this device model was properly reporting its xdpi and ydpi: ~304 and ~306, respectively.
We're accessing this information through DisplayMetrics like so:
DisplayMetrics dm = getResources().getDisplayMetrics();
xdpi = dm.xdpi;
ydpi = dm.ydpi;
Has anyone else noticed these metrics to be inconsistent/unreliable? Is there a more accurate way to access this information?
Edit: I found this post regarding xdpi/ydpi inaccuracies. Both Romain and Dianne seem to acknowledge the issue - so the fact that the DisplayMetrics docs don't make note of these unreliable properties seems quite irresponsible to me.
From API 17 you can call
getRealMetrics
to get more accurate results.From Display documentation