Android: How to detect when multiple http requests complete

删除回忆录丶 提交于 2019-12-25 06:02:19

问题


I have this app that onResume() creates five fragments. Each fragment then opens a http connection to download an XML file. This is done using an AsyncTask. In the async tasks onPostExecute() the XML file is processed and the result rendered in a tab.

I'm trying to figure out how to display a "Loading..." screen that is removed when the last fragments XML file is processed.

I've looked at onPreExecute() to setup a ProgressDialog but I only want to do it once...

I could create a counter that was incremented when my fragment was created and... decremented(?) when the XML processing completes and then just wait for it to reach zero. But that's not really very elegant. Also I would like to make it "future proof" so that I don't have to change the code when I add tab #6.

Please help...

来源:https://stackoverflow.com/questions/25608795/android-how-to-detect-when-multiple-http-requests-complete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!