2013年11月12日 星期二

WeakReference listener in API

在找 OnSharedPreferenceChangeListener 範例抄時找到這個

SharedPreferences keeps listeners in a WeakHashMap. This means that you cannot use an anonymous inner class as a listener, as it will become the target of garbage collection as soon as you leave the current scope.

SharedPreferences.onSharedPreferenceChangeListener not being called consistently

靠... 這很容易踩到啊 =_=

沒有留言:

張貼留言