0

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

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51

1 Answers1

0

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

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
  • thank you for your reply. But I mainly use MODE_NIGHT_YES to make changes, and then make changes through the system, but there is no change, the app must be restarted to change – Yeh SHIH Wen Mar 15 '21 at 01:39
  • i'm not sure how else to answer your, what you're doing won't work because you app doesn't know that anything has changed – a_local_nobody Mar 15 '21 at 04:49