Swapnil Swapnil - 2 months ago 10
Android Question

Which thread do we get the call back on when calling findInBackground() on Parse android API

I have been writing an android application using the

as backend as a service for my application. When I query a class to get the objects from my server, I do it using
and then receiving the callback like this:

query.findInBackground(new FindCallback<Shruti>() {
public void done(List<Shruti> objects, ParseException e) {

My question is that on which thread do I receive the callback on the
method. Is it still the same thread which is started by calling
or is it the thread from which I called
? 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
methods (for instance,
is a synchronous option for
) 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).