You should be using a SharedPreference
and then accessing that in your main activity. I recommend you reading up at http://developer.android.com/guide/topics/ui/settings.html because it seems like you are implementing your settings activity incorrectly. The part you might be specifically interested in is the "Read Preferences" section. However, I strongly suggest you read through the whole thing and then implement your settings the proper way.
Updated answer with the 3 different ways (that I can think of):
1) Start your preference activity using startActivityForResult()
, then in your onActivityResult()
access the SharedPreference
and make your necessary changes. See here
2) Register a SharedPreferenceChangeListener
with your MainActivity, which will be called when any changes happen to your SharedPreference
. See here for a detailed discussion. Also see my initial response.
3) In your MainActivity's onResume()
, access the SharedPreference
and then make your changes there. I do not like this method because you will be cluttering onResume()
with more logic and you will also probably have to have a variable that keeps track of the state of the variable you are interested in.
I would personally go with option 2 because the callback was created for this exact purpose.