检测 Android 暗色模式是否开启

检测 Android 暗色模式是否开启:

1
2
3
4
private static boolean isSystemDarkModeEnabled(Context context) {
return (context.getResources().getConfiguration().uiMode &
Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
}