Reputation: 589
Apparently you can use this:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_TIME);
But MODE_NIGHT_AUTO_TIME
is depreciated.
Automatic switching of dark/light based on the current time is deprecated. Considering using an explicit setting, or MODE_NIGHT_AUTO_BATTERY.
For what possible reason could such an amazing function be depreciated? And what is the alternative "explicit setting" they talk about?
Upvotes: 1
Views: 273
Reputation: 402
I guess it's better to follow the system settings. If the system is using dark mode, you app will automatically switch to dark mode since most devices support schedule dark mode. If you want your app to switch with time, I guess you have to do it manually like check the time before initializing your views and decide whether to use dark mode or light mode.
Upvotes: 1
Reputation: 74066
If you are following the guidelines for supporting dark mode you do not need to worry about if/when its dark/light mode.
The user can setup schedules for if/when the device switches between modes and then app themes will adapt accordingly hence there is no need for that anymore
Upvotes: 1