warning: [deprecation] getMetrics(DisplayMetrics) in Display has been deprecated

Reference: https://developer.android.com/reference/android/view/Display#getMetrics(android.util.DisplayMetrics)

This method is deprecated from API level 30, so if you want to get the dimensions of the application window then you can safely manage this situation with:

if (Build.VERSION.SDK_INT >= 30) {
    WindowManager windowManager = (WindowManager)
        getSystemService(WINDOW_SERVICE);
    final WindowMetrics metrics = windowManager.getCurrentWindowMetrics();
    // Gets all excluding insets
    final WindowInsets windowInsets = metrics.getWindowInsets();
    Insets insets =
     windowInsets.getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars()| WindowInsets.Type.displayCutout());

    int insetsWidth = insets.right + insets.left;
    int insetsHeight = insets.top + insets.bottom;

    // Legacy size that Display#getSize reports
    final Rect bounds = metrics.getBounds();
    final Size legacySize = new Size(bounds.width() - insetsWidth,bounds.height() - insetsHeight);
}