Search code examples
androiddarkmode

some Question About dark mode from android


When I use

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

to open & close dark mode. then i test using my phone's dark mode Button(not my app code), then my APP isn't changing.

why? How can I do?

MY phone is android 9


Solution

  • from what i understand in your question, what you're looking for is:

    MODE_NIGHT_FOLLOW_SYSTEM

    when you're using MODE_NIGHT_YES or MODE_NIGHT_NO it forces those onto your application, but you need to use MODE_NIGHT_FOLLOW_SYSTEM if you want to follow what the device is using