Using PreferencesActivity from a widget?

后端 未结 2 1791
孤街浪徒
孤街浪徒 2020-12-18 13:04

The PreferenceActivity seems like a really easy helper class to manage the preferences of an app.

I\'d like to also use that same class from the widget.

On t

2条回答
  •  天命终不由人
    2020-12-18 13:50

    You should be able to tell when the Preference edits are complete by implementing a SharedPreferences.OnShredPreferenceChangeListener. Using this, you could update only when certain keys are changed, or unconditionally when any are changed. Remember to register it in your PreferenceActivity onCreate and unregister it in the onDestroy.

    In this case, you can do something similar to Android: How do I force the update of all widgets of a particular kind within the listener to cause all of your widgets to update based on a SharedPreference change.

    It's an old question, so this may not be relevant anymore.

提交回复
热议问题