Looking at the official documentation can be obtained from UiModeManager
.
I've also found that tutorial that implements it from a simple way.
Summing up:
Android Day Night mode, you can differentiate with the suffix -night
and in the definition of the theme Theme.AppCompat.DayNight.DarkActionBar
the colors of the night interface will be in values-night/colors.xml
To set it to detect it automatically
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
If you want to force it to be seen in Night mode
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
If you want to see it in the default mode it means day mode.
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
Downloadable tutorial example: DayNightThemeExample