Search code examples
androidasynchronouscallbackasynctaskloader

Run asynchronous method in loadInBackground of AsyncTaskLoader


I would like to run asynchronous server call using AsyncTaskLoader. Method loadInBackground() should return the result synchronously. I am returning null and I call deliverResult() in callback which is executed on manually created HandlerThread. This implementation is sending to UI null at first, then (when async server operation is done) real data. I'm not sure this is good solution.

How to implement custom AsyncTaskLoader properly, where I want to load data by asynchronous server calls (thus using callbacks)?

Thanks for any help


Solution

  • use join() on manually created HandlerThread (without code it's hard to give a working example)