I don’t want to be using:
onSharedPreferenceChanged
Because my Live Wallpaper is reinitialized every time something happens with a settings (making it crash, stack overflow!)
Instead I want to be calling the
onDestroy()
Methed from the settings during the main activity which has ATM:
SharedPreferences.OnSharedPreferenceChangeListener
I want to do this because it saves on performance & allows me to reinitialise my main class.
How would I go around doing this?
The
OnSharedPreferenceChangeListenerandOnSharedPreferenceChanged()are SUPPOSED to be called whenever a setting is changed? That’s literally their purpose for being there, so when settings are changed their effects are seen immediately.I’m not quite understanding why you want to call onDestroy()? This is only called when an application is going down… so I guess you could simply say:
If you’re looking to restart your application why not say finish you activity, and start a new one via:
Thus you’re completely re-initializing your activities with the new data?
I would however stick with your
OnSharedPreferenceChanged()and just try to find what is actually causing your errors, rather than abstracting the process.[Update]
MainActivity.java
PreferenceActivity.java