I'm making an Android application using Kotlin. It contains App Theme color list so the user can select one color from it, and then I save this color in Shared Preferences.
I've done with all Shared Preferences and XML values stuff, and I've succeeded to change the theme smoothly in the settings activity, and when I reopen the application I find the saved color successfully in settings activity.
The problem is: the changes happens on settings activity only, not in the whole app, and if I want to affect all activities I should use setTheme()
in each activity's onCreat()
.
I don't want to do that since my application has many activities.
Is there better approach to achieve that.
I tried to call setTheme()
method on Application
class, but it doesn't work.