Summary: A strong reference to the listener should be kept when calling `registerOnSharedPreferenceChangeListener`, otherwise the listener can get garbage-collected and stop working. Mentioned in the Android SDK docs [here](https://developer.android.com/reference/android/content/SharedPreferences.html#registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener)): > Caution: The preference manager does not currently store a strong reference to the listener. You must store a strong reference to the listener, or it will be susceptible to garbage collection. We recommend you keep a reference to the listener in the instance data of an object that will exist as long as you need the listener. Closes https://github.com/facebook/Sonar/pull/131 Differential Revision: D8751484 Pulled By: xiphirx fbshipit-source-id: e46715d637c89491770c266fc22c27db41beb042
5.0 KiB
5.0 KiB