WindowManager windowManager = getWindowManager(); int width = windowManager.getDefaultDisplay().getWidth(); int height = windowManager.getDefaultDisplay().getHeight();In this example, we obtain the width and height of the current device window using the WindowManager object obtained through the getWindowManager() method. The package library for the getWindowManager() method is android.view.WindowManager.