title: getSize() deprecated in API level 30
body: <p>I used the getSize() method to get the screen sizes:</p>
  <pre><code>override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
      val fragmentActivity = requireActivity()
      ...
      val wm = fragmentActivity.getSystemService(Context.WINDOW_SERVICE) as WindowManager 
      val display = if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.R) {
          fragmentActivity.display
      } else {
          wm.defaultDisplay 
      }
      val size = Point()
      display?.getSize(size)
      
      // get screen sizes
      val width = size.x
      val height = size.y
      ...
  }
  </code></pre>
  <p>But with API level 30 the method getSize() is declared deprecated.</p>
  <p>What can be used instead of getSize() for obtain screen sizes?</p>
  <p>Thank you for any comment/answer!</p>
  <p><strong>Solution</strong>:</p>
  <pre><code>val wm = fragmentActivity.getSystemService(Context.WINDOW_SERVICE) as WindowManager
  val width: Int
  val height: Int
  if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.R) {
      val windowMetrics = wm.currentWindowMetrics
      val windowInsets: WindowInsets = windowMetrics.windowInsets
  
      val insets = windowInsets.getInsetsIgnoringVisibility(
            WindowInsets.Type.navigationBars() or WindowInsets.Type.displayCutout())
      val insetsWidth = insets.right + insets.left
      val insetsHeight = insets.top + insets.bottom
  
      val b = windowMetrics.bounds
      width = b.width() - insetsWidth
      height = b.height() - insetsHeight
  } else {
      val size = Point()
      val display = wm.defaultDisplay // deprecated in API 30
      display?.getSize(size) // deprecated in API 30
      width = size.x
      height = size.y
  }
  </code></pre>