Android 如何在一个应用程序中同时使用setDefaultNightMode和getConfiguration().uiMode?

Android 如何在一个应用程序中同时使用setDefaultNightMode和getConfiguration().uiMode?,android,android-night-mode,android-darkmode,Android,Android Night Mode,Android Darkmode,我找不到解决这个问题的办法。在我的主要活动中,我使用此命令设置应用程序暗模式: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); 但是,我想知道,是否使用此命令激活了设备暗模式: int dM = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; 如果设备处于暗模式,uiMode将更改其

我找不到解决这个问题的办法。在我的主要活动中,我使用此命令设置应用程序暗模式

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
但是,我想知道,是否使用此命令激活了设备暗模式:

int dM = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
如果设备处于暗模式,uiMode将更改其值。问题是,如果调用setDefaultNightMode,它也会将uiMode更改为相同的值。如何仅检测设备暗模式