code: public static int getColor(Resources resources, int id) {
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
              return resources.getColor(id, null);
          } else {
              return resources.getColor(id);
          }
      }
docs: Returns a themed color integer associated with a particular resource ID.
  If the resource holds a complex {@link ColorStateList}, then the default
  color from the set is returned.
  
  @param resources Resources
  @param id        The desired resource identifier, as generated by the aapt
  tool. This integer encodes the package, type, and resource
  entry. The value 0 is an invalid identifier.
  @return A single color value in the form 0xAARRGGBB.