I'm currently developing an app in Kotlin and while testing it on my Redmi Note 9 pro (MIUI 12), I tried to switch my app to light theme by deactivating dark mode for my app only in the settings. However it didn't work and my app is still in dark theme.
I've already tried the answer on the most popular topic on this subject, like adding this line in my res/values/themes.xml
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
or this one in my AndroidManifest.xml
<activity
...
android:configChanges="uiMode"
>
but nothings work, and I didn't find any MIUI documentation on the subject, so I hope someone has found the solution at this problem
MIUI has its own feature, called force dark mode which is working in a strange way. Even if you disable it, it tries to change colors (as resources or something like that on system UI level). In most cases disabling it with forceDarkAllowed
in theme plus AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
in activity or app onCreate override works it out.
But i found that if you open another activity, some payment SDK's activity for example, which does not restrict force dark theme feature, you may found that MIUI still do some changes to the colors of your app after you return from that activity.
Still have no clue how to fix this issue, but in your case adding string I mentioned to onCreate() might be the solution.