A colleague of mine tested one of my compose apps on a “Moto Z2 Play” running Android 9.0 and it turned out all composables render always in dark mode.
Android 9 didn’t have dark mode yet but it had a “device theme” setting under “settings -> display -> advanced”.
It seems changing that has no effect whatsoever. Every composable in the app is always displayed as if
isSystemInDarkTheme()
always returned
true
.
I have tested on an API28 emulator and can’t reproduce: the composables are always rendered in light mode (as they are supposed to).
Has anyone encountered a similar situation?
c
cb
07/27/2021, 2:24 PM
My guess is that some app has called
UiModeManager.setNightMode()
. That API was a global toggle up until API 29 so is likely to be the reason
➕ 1
today i learned 1
🙏 1
cb
07/27/2021, 2:27 PM
If they run an app and call the following, it will reset the value:
Copy code
val mgr = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
mgr.nightMode = UiModeManager.MODE_NIGHT_NO