Is there a way to reliably calculate the screen size / screen zoom level, which can be changed in Settings App -> Display?
I found here that you can use DisplayMetrics.DENSITY_DEVICE_STABLE and densityDpi to calculate the "zoom level". This generally works for most devices, but not on certain Samsung devices where you can change the resolution.
On a Samsung Galaxy S10 and the resolution set to FHD+:
- DENSITY_DEVICE_STABLE reports 420
- standard display zoom: densityDpi reports 420
- next zoom level: densityDpi reports 450
420 / 420 = 1
450 / 420 = 1.0714285
Works as expeced, yay!
Now we change the resolution:
Samsung Galaxy S10 and the resolution set to WQHD+:
- DENSITY_DEVICE_STABLE reports 420
- standard display zoom: densityDpi reports 560
560 / 420 = 1.3333334
We can't reliably calculate the zoom level since densityDpi reports different values for the same zoom level on different resolutions, but DENSITY_DEVICE_STABLE stays the same, regardless of what resolution is set.
Is there any other way you can do this?