According to Android docs:
Note: On API 22 and below, changes to the night mode are only
effective when
the Configuration#UI_MODE_TYPE_CAR or Configuration#UI_MODE_TYPE_DESK mode
is enabled on a device. On API 23 through API 28, changes to night
mode are always effective.
Starting in API 29, when the device is in car mode and this method is
called, night mode will change, but the new setting is not persisted
and the previously persisted setting will be restored when the device
exits car mode.
Changes to night mode take effect globally and will result in a
configuration change (and potentially an Activity lifecycle event)
being applied to all running apps. Developers interested in an
app-local implementation of night mode should consider
using AppCompatDelegate.setDefaultNightMode(int) to manage the -night
qualifier locally.
This method only works in Android 10 if car mode is enabled.