使用时
getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK
检查应用程序当前处于什么模式,
int currentNightMode = getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK
switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO:
// Night mode is not active, we're in day time
case Configuration.UI_MODE_NIGHT_YES:
// Night mode is active, we're at night!
case Configuration.UI_MODE_NIGHT_UNDEFINED:
// We don't know what mode we're in, assume notnight
}
如果AppCompatDelegate.MODE_NIGHT_YES早先调用它
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
是回归currentNightMode吗Configuration.UI_MODE_NIGHT_YES?
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM之前设置时它会返回什么
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
并且设备已从亮变为暗(或从暗变为亮)?