views:

305

answers:

2

I am calling a PreferenceActivity from another activity and then updating the application state (ie: changing the font size) on onActivityResult, based on the preference changes.

I was thinking it would be better to put the state update logic in the PreferenceActivity. That way I don't have the duplicate the logic in each activity that calls the PreferenceActivity.

What's the best or correct way to do this?

+1  A: 

Have any Activity (or other component) that cares about preference changes register a preference change listener via registerOnSharedPreferenceChangeListener(). Then, when the preferences change by any means, they will find out about it and can react accordingly.

CommonsWare
Oh. I didn't know that even existed. Thanks a lot, CommonsWare!
hgpc
A: 

The PreferenceActivity should handle all the preference setting. Your other activities should read what those settings are when they run and adjust themselves accordingly.

Scienceprodigy