-1

Changing the theme(light/dark& default) from the dialog box using option menu.Is there any way to keep theme (light /dark) active through out the app in kotlin even after you reopen the app. I used shared preferences but unable to access that in oncreate

Saphira
  • 1
  • 2
  • I think this might be helpful https://stackoverflow.com/a/61891471/12153321 . As for saving the state, you have to save it in shared preferences. – Javlon Jul 28 '22 at 05:06

1 Answers1

0

In your app application class :

override fun onCreate() {
        super.onCreate();      
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
}
Kishan Mevada
  • 662
  • 1
  • 6
  • 17