code: private boolean isActivityThemeLight() {
          try {
              TypedValue val = new TypedValue();
  
              //Reading attr value from current theme
              getActivity().getTheme().resolveAttribute(R.attr.isLightTheme, val, true);
  
              //Passing the resource ID to TypedArray to get the attribute value
              TypedArray styledAttributes =
                      getActivity().obtainStyledAttributes(val.data, new int[]{R.attr.isLightTheme});
              boolean lightTheme = styledAttributes.getBoolean(0, false);
              styledAttributes.recycle();
  
              return lightTheme;
          } catch (RuntimeException e) {
              //Resource not found , so sticking to light theme
              return true;
          }
      }
docs: This method resolves the current theme declared in the manifest