Reputation: 53
I have a problem with my app that when I toggling the system theme it restart the entire app to the main fragment, How can I prevent this that when switching to dark mode or light it wont restart the entire app.
Upvotes: 5
Views: 1672
Reputation: 111
I have the same problem, and I spend a lot of time trying to find a solution. Then, I found this article on Medium:
Applying dark mode without recreating your app
You need to specify uiMode on your Activity and handle the theme state changes by yourself.
<activity
android:name=".MyActivity"
android:configChanges="uiMode" />
Upvotes: 4