I have got a Samsung Galaxy S4 Active
When I execute on Android, the following code:
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width=dm.widthPixels;
int height=dm.heightPixels;
int dens=dm.densityDpi;
double wi=(double)width/(double)dens;
double hi=(double)height/(double)dens;
double x = Math.pow(wi,2);
double y = Math.pow(hi,2);
double screenInches = Math.sqrt(x+y);
I obtain
width = 1080
heigh = 1920
dens = 480
So, is the used formula is correct, screenInches
is 4.589. But the specification said that the screenInches size is 5.
I have also tried with my Samsung Galaxy SII that gives me:
width = 480
heigh = 800
dens = 240
that corresponds to a screenInches
of 3.887 instead of 4.3 (as said in the specs)
Why there is this difference between the declared size in inches and the size I obtain?
EDIT: It seems that densityDpi returns one of these values: (120, 160, 213, 240, 320, 480 or 640 dpi).