Search code examples
androidsharedpreferencespreferenceactivity

PreferenceActivity calling methods of the main activity


In my Android application, I've just created a User Settings activity (extending PreferenceActivity).
I want a few settings/buttons to trigger some methods from my main activity. How should I do that?

a) Make everything in my main activity static? (doesn't seem to be a good idea)

b) Send main activity as Parcelable when opening User Settings? (putExtra())

c) (another suggestion?)


Solution

  • I don't know specifically what you are doing, but since it's preferences I would save my preferences in SharedPreferences, and then I would make my MainActivity implement SharedPreferences.OnSharedPreferenceChangeListener and call it's methods when the right preferences were changed.