AppCompatDelegate.setDefaultNightMode craches the application

355 views Asked by At

I want to change theme mode to dark like below:

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)

I use it in the avtivity creation function and get this error:

java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter view

Considering the activity has some fragments, I think I should recreate the activity and send it to fragments, but I don't know how. Any help will be appreciated.

1

There are 1 answers

0
LeFarmico On

I guess it's not relevant now but If someone finds it useful I'll try to help.

If You have used a fragment in your activity layout try to change it to androidx.fragment.app.FragmentContainerView.