[Solved] My app is crashing when I switch to dark mode
[ad_1] You’re casting the nullable Activity to a non-null Context in a listener that might be called when the Fragment it no longer attached to an Activity, which means the Activity would be null at that point. You should generally avoid casting with as. In this case, it masks what the problem was. At least … Read more