should you create new Async Tasks for every different call or use the same one

前端 未结 4 834
[愿得一人]
[愿得一人] 2020-12-18 12:44

So I have an app that will make multipe HTTP Post/Gets

E.G. Login, getThisData, getThatData, sendThis, sendThat

Is it better to have a seperate AsyncTask to

4条回答
  •  梦毁少年i
    2020-12-18 13:18

    If you want to create one instance of AsyncTask, and execute() it several times, no:
    Execute AsyncTask several times

    If you are asking about designing: whether you should write one class to get different kind of data? It really depends on your circumstances:
    If these HTTP call supposed to be sequential, you can put them in one AsyncTask class.
    If they have lot in common, just point to different URIs, you can write a call(String uri) method, and invoke that method in your AsyncTask. This case, I think one AsyncTask is also enough.

提交回复
热议问题