问题
I have an app which uses PreferenceActivity to define time period to run scheduled tasks. But I can't the right method to Override in PreferenceActivity to make tasks rescheduled on period values changed.
Does anyone know what method is called when PreferenceActivity saves values? I am using API 8 level and seems that onSaveInstanceState(Bundle outState) is not that I am looking for.
回答1:
There is no callback for changed preferences in a PreferenceActivity. But you can use the normal OnSharedPreferenceChangeListener that you would use everywhere else. Just register it in and you'll get notified when a preference changes. Check for the correct key in the callback and reschedule your tasks.
来源:https://stackoverflow.com/questions/6962942/what-method-is-called-when-preferenceactivity-saves-values