code: @SuppressLint("NewApi")
      public static Point getDisplaySize(WindowManager manager) {
          Display display = manager.getDefaultDisplay();
          if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
              Point size = new Point();
              display.getSize(size);
              return size;
          } else {
              Point size = new Point();
              size.x = getDisplayWidth(manager);
              size.y = getDisplayHeight(manager);
              return size;
          }
      }
docs: Get the display width and height.
  @param manager the window manager.
  @return the display size.