运行 AsyncTaskLoader的loadInBackground中的异步方法

Run asynchronous method in loadInBackground of AsyncTaskLoader

我想 运行 使用 AsyncTaskLoader 进行异步服务器调用。方法 loadInBackground() 应该 return 同步结果。我 returning null 并在手动创建的 HandlerThread 上执行的回调中调用 deliverResult()。此实现首先发送到 UI null,然后(当异步服务器操作完成时)实际数据。我不确定这是好的解决方案。

如何正确实现自定义 AsyncTaskLoader,我想通过异步服务器调用加载数据(因此使用回调)?

感谢您的帮助

使用join() on manually created HandlerThread(没有代码很难给出一个有效的例子)