title: How to reliably calculate the screen size / screen zoom level when you can set different screen resolutions?
body: <p>Is there a way to reliably calculate the screen size / screen zoom level, which can be changed in Settings App -&gt; Display?</p>
  <p>I found <a href="https://www.reddit.com/r/androiddev/comments/80y795/how_to_programmatically_check_if_user_has/" rel="nofollow noreferrer">here</a> that you can use <a href="https://developer.android.com/reference/android/util/DisplayMetrics#DENSITY_DEVICE_STABLE" rel="nofollow noreferrer">DisplayMetrics.DENSITY_DEVICE_STABLE</a> and <a href="https://developer.android.com/reference/android/util/DisplayMetrics#densityDpi" rel="nofollow noreferrer">densityDpi</a> to calculate the &quot;zoom level&quot;.
  This generally works for most devices, but not on certain Samsung devices where you can change the resolution.</p>
  <p>On a Samsung Galaxy S10 and the resolution set to FHD+:</p>
  <ul>
  <li>DENSITY_DEVICE_STABLE reports 420</li>
  <li>standard display zoom: densityDpi reports 420</li>
  <li>next zoom level: densityDpi reports 450</li>
  </ul>
  <p>420 / 420 = 1</p>
  <p>450 / 420 = 1.0714285</p>
  <p>Works as expeced, yay!</p>
  <p>Now we change the resolution:</p>
  <p>Samsung Galaxy S10 and the resolution set to WQHD+:</p>
  <ul>
  <li>DENSITY_DEVICE_STABLE reports 420</li>
  <li>standard display zoom: densityDpi reports 560</li>
  </ul>
  <p>560 / 420 = 1.3333334</p>
  <p>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.</p>
  <p>Is there any other way you can do this?</p>