Officially dark theme is available in Android 10, but in reality, dark theme available in Android 9 MIUI 11 for example. Is there a way to check programmatically if OS dark theme available or not? I tried to check it through the Configuration#uiMode
field:
public boolean isSystemDarkAllowed() {
final Configuration configuration = context.getResources().getConfiguration();
final int nightMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK;
return nightMode != Configuration.UI_MODE_NIGHT_UNDEFINED;
}
but it is not working, for Android 5 it returns true