Accessing Volley Response With Callback Interfaces
I m trying to extract android volley response to a member variable of the same class. I used callback interfaces to perform this task : public void getData(MyCustomListener customL
Solution 1:
Ok. In reference to the comment above, I am writing some steps you should try since I do not have a clear picture of what might be wrong.
Let's start with your MyCustomListener
. I do not know why are you setting the response type to Object
. If it is to use this in multiple requests then you can modify it like the following with generics
publicinterfaceMyCustomListener<T> {
publicvoidonResponse(T response);
publicvoidonError(String error_response);
}
then use it like this when a callback is needed
getData(newMyCustomListener<List<CompleteCartProItem>>() {
@OverridepublicvoidonResponse(List<CompleteCartProItem> response) {
completeCartProItems.addAll(response);
}
@OverridepublicvoidonError(String error_response) {
//handle error
}
});
Also make sure you are not re-initialising completeCartProItems
elsewhere after the callback.
Not really sure if the following will fix your issue but make sure that your callback is executed in the UI thread, too.
Post a Comment for "Accessing Volley Response With Callback Interfaces"