You can get the current mode using the following code,
int currentNightMode = getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO:
case Configuration.UI_MODE_NIGHT_YES:
case Configuration.UI_MODE_NIGHT_UNDEFINED:
}
The following article by Chris Banes explains this beautifully.
source
share