I'm trying to find the REAL screen size in inches of a device and i tested some code found on stackoverflow and google with getRealMetrics(), but the code does not work well on all the devices.
For example on NEXUS 5 it works fine and tells that the device haves 4.96 inches, but in BQ Aquaris E5 FHD with KitKat 4.4.2 it does not work well and tells that the device haves 4.59 inches (it haves 5 inches...)
This is the code that does not work properly:
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics);
double d1 = displayMetrics.widthPixels / displayMetrics.xdpi;
double d2 = displayMetrics.heightPixels / displayMetrics.ydpi;
double deviceInches = Math.sqrt(d1 * d1 + d2 * d2);
0 comments:
Post a Comment