I have been writing an android application using the parse-server
as backend as a service for my application. When I query a class to get the objects from my server, I do it using ParseQuery.findInBackground()
and then receiving the callback like this:
query.findInBackground(new FindCallback<Shruti>() {
@Override
public void done(List<Shruti> objects, ParseException e) {
...................
...................
});
My question is that on which thread do I receive the callback on the done()
method. Is it still the same thread which is started by calling findInBackground()
or is it the thread from which I called findInBackground()
? I curious about this because if I want to do some processing with the retrieved objects in the background as well, do I need to again call the respective do-in-background method or since the callback I get is already in the different thread, I can just call the synchronous
methods (for instance, ParseQuery.find()
is a synchronous option for ParseQuery.findInBackground()
) assuming that I am still in the background thread?
I think the callback method will execute on the thread you used to call findInBackground
, so if that's the UI thread and you have more network to do there, you'll need to use other background threads. You can verify by calling the synchronous method and see if you get a NetworkOnMainThreadException
(on a recent enough device).