AsyncTaskLoader onLoadFinished with a pending task and config change

后端 未结 4 1236
醉酒成梦
醉酒成梦 2021-02-02 10:11

I\'m trying to use an AsyncTaskLoader to load data in the background to populate a detail view in response to a list item being chosen. I\'ve gotten it mostly work

4条回答
  •  面向向阳花
    2021-02-02 10:47

    A possible solution is to start the AsyncTask in a custom singleton object and access the onFinished() result from the singleton within your Activity. Every time you rotate your screen, go onPause() or onResume(), the latest result will be used/accessed. If you still don't have a result in your singleton object, you know it is still busy or that you can relaunch the task.

    Another approach is to work with a service bus like Otto, or to work with a Service.

提交回复
热议问题