when (this.resources?.configuration?.uiMode?.and(Configuration.UI_MODE_NIGHT_MASK)) {
          Configuration.UI_MODE_NIGHT_YES -> {
          //write code here for night mode
          Configuration.UI_MODE_NIGHT_NO -> {
          //write code here for light mode
          Configuration.UI_MODE_NIGHT_UNDEFINED -> {
            //write code here when undefined

      Kotlin language logo
      color mode

      Kotlin recipes

      The code sets the mode of the user interface to either night mode or light mode, depending on the value of the resource's configuration.uiMode property.


        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.