I'm developing an application where images and layouts adapt to the logical density of the device.
Is it possible to get screen dpi of the device through Java?
I'm developing an application where images and layouts adapt to the logical density of the device.
Is it possible to get screen dpi of the device through Java?
It is possible to obtain the logical density through the code
getResources().getDisplayMetrics().density;
It will return you:
0.75 - ldpi (low resolution)
1.0 - mdpi (medium resolution)
1.5 - hdpi (high resolution)
2.0 - xhdpi (great resolution)
3.0 - xxhdpi (+ optimal resolution)
4.0 - xxxhdpi (excellent)
reference: density