Reputation: 440
I am implementing Dark/Light mode in android.
Implementated using below code:
Theme: Theme.MaterialComponents.DayNight.NoActionBar
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
and
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
Reference: https://developer.android.com/guide/topics/ui/look-and-feel/darktheme and https://stackoverflow.com/a/61891471/5707364
Its working fine in Emulators with Android 10, 11 and 12 as well as Real device One plus 5T, Oppo oppo f3, etc But it is not working in below device. It always remains in dark theme.
Device model: Redmi 8A Android Version: 10QKQ1.191014001 MIUI Version: MIUI Global 12.5.2 Stable (12.5.2.0(QCPMIXM)) CPU: Octa-core Max 2.01GHz
Activity is recreated, but no effect. check video: https://www.loom.com/share/796ee5029ee14addb9d95514691cd02e
Please help
Upvotes: 1
Views: 2774