0

Changing night mode doesn't work on my mobile (it works in emulator)

night mode is set to my mobile's system mode(dark mode)

Since the new android studio there is default night mode theme in the starter code

I need to make a app with only Light mode I've checked many solutions where we can change the theme using AppCompatDelegate method example here, and docs

Zoe
  • 27,060
  • 21
  • 118
  • 148
Farees Hussain
  • 181
  • 1
  • 6

1 Answers1

0

You could set the theme to light or dark mode via the activity file. Here is the snipit of code you need:

    fun useAppContext() {
    // Context of the app under test.
    val appContext = InstrumentationRegistry.getInstrumentation().targetContext
    assertEquals("com.fcs.darktheme", appContext.packageName)
}

You can check out the video that I found this in. I persoanlly use Java and the principle worked for me. I commented in that video should you need the Java code. It is done with kotlin here: https://www.youtube.com/watch?v=bWLnf2nqTl4&lc=UgximPI3XmiVgRa9k3N4AaABAg.9HePgMqRxF-9HeU3b16R-b&feature=em-comments

DTD
  • 11
  • 3