We want to set the localNightMode of an activity before the activity is created, to avoid an activity restart.
Therefore, in the onCreate we call:
delegate.localNightMode = NIGHT
delegate.applyDayNight()
super.onCreate(savedInstanceState)
This works. Mostly. For some reason, sometimes, some resources use the color values from the day instead of the night values. So our app is in night, but 1-2 texts or a drawable use the wrong color. This is fixed with the next activity restart (rotation, activity resume, etc.)
If we switch the order in the onCreate:
super.onCreate(savedInstanceState)
delegate.localNightMode = NIGHT
delegate.applyDayNight()
our activity restarts immediately during the creation. You see the day style for half a second, then it switches to night mode. Then everything is correct.
We have tried with our without delegate.applyDayNight(). The delegate.applyDayNight() helps, but does not fix the issue.
Do you have any idea what might be wrong? Do we need to call something else?