code: @SuppressLint("NewApi")
      @SuppressWarnings("deprecation")
      public static int getDisplayWidth(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.x;
          } else {
              return display.getWidth();
          }
  
      }
docs: Get the display width.
  @param manager the window manager.
  @return the display width.