Calculate PPI of Android Device
android, device, ppi
Solution
It's easy like one-two-three =) Let's caculate PPI to Nexus 5, for example.
float LCD_Diagonal = 4.95f;
int screenHeightPx = 1920;
int screenWidthPx = 1080;
float PPI = (float)Math.sqrt((double)(screenWidthPx*screenWidthPx + screenHeightPx*screenHeightPx))/LCD_Diagonal;
Log.e(TAG, "display_page_screen_ppi: " + String.format(Locale.getDefault(),"%d %s", Math.round(PPI), "ppi"));
In result we have `445 ppi` that's true according with specs.
Problem
How do I calculate PPI of Android device. Most specifically Android Tablets. Take a Note that I want to calculate PPI of the device and not DPI.