When a user opens preferences on my app he may make changes for example changing the app theme.
The documentation for ContextThemeWrapper.setTheme(int)
says:
Set the base theme for this context. Note that this should be called before any views are instantiated in the Context (for example before calling
setContentView(View)
orinflate(int, ViewGroup)
).
So my first thought was restarting the app onResume()
when the user changed the preferences. However I noticed that sometimes the process of restarting the activity is seamless while other times the activity is closed, the home screen is seen and only after some seconds the app opens again.
I'm wondering if there is a way to change handle the preferences changes. Like for instance changing the theme after onResume
without restarting the activity or restarting the activity on the background while the user is on preferences.
What's the right way to handle this?