'System Dark mode setting problem (More Dark mode options)

Hello‚ I had a problem with the night mode in my program. Switching from the phone system to night mode did not change the black text to white. It was just black. I found a solution through stackoverflow:

<item name="android:forceDarkAllowed" tools:targetApi="q">false</item> 

I added this code to Theme night and light.

It all started to work well though.

Now, if you try to disable the dark mode for the application from this part of the phone settings, the application will not return! It only goes back when the full phone goes back.

This setting: enter image description here

From this part I turned off my app and there is no change. It simply ignores this part. Only if I turn off the phone completely dark mode, then the app also returns to light mode.

Please help me!



Solution 1:[1]

You can put this in the first line of your launcher activity's onCreate method to disable night mode in your app.

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

If you want to use Force Dark, you make sure that the app supports Android 10 and above. Also if you want to support it in dark mode, I recommend you to read this document. https://developer.android.com/guide/topics/ui/look-and-feel/darktheme

Solution 2:[2]

Just add this line of code to your themes-night.xml file

<item name="android:textColor">@android:color/white</item>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Enes
Solution 2 chisom emmanuel