warning: [deprecation] getDefaultDisplay() in WindowManager has been deprecated

Reference: https://developer.android.com/reference/android/view/WindowManager#getDefaultDisplay()

This method is deprecated from API level 33, so you can safely manage this situation with:

Display display;
if (Build.VERSION.SDK_INT >= 30)
    display = this.getDisplay();
else {
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    display = wm.getDefaultDisplay();
}

Be careful that this is referred to an activity that is displayed on that display or read major documentation here: https://developer.android.com/reference/android/content/Context#getDisplay()

Leave a Reply

Your email address will not be published. Required fields are marked *