Closed ghost closed 8 years ago
WeakReference maybe the key point, after GC it clear from memory, and it turn out to be null.
This is actually a feature because it avoids memory leaks caused by passing your activity/fragment as the callback. I suppose I should have documented this a bit better...
To avoid this issue, you can store that callback in a variable and pass that variable instead.
thank you! I have try that before, but I store request.callback instead. After you remind me to store callback, so I try to store request.callback.get() response and it work now!
request.callback; -> still null request.callback.get(); -> callback work fine
Glad to hear your problem is solved!
Perhaps I'll make an optional parameter in the future for PkRSS to automatically hold strong references. In the meantime, you know what to do. :)
I load a RSS and use callback like this
And I find onPreload work but onLoaded not call, I find out the reason is invokeCallback return 0, because request.callback.get() get null, but it not null when onPreload notify callback
...
after parse articles from response, request.callback.get() become null. but I have no idea what happen