gpt4 book ai didi

单个AsyncTask中的Android多个Web服务调用

转载 作者:行者123 更新时间:2023-11-29 00:35:45 25 4
gpt4 key购买 nike

如何从单个 Asynctask 调用多个 Web 服务调用,提前致谢。

最佳答案

它们是同步的吗?然后调用第一个,第二个...

public class WSTask extends AsyncTask<Void,Void,AccountsOverview_LABean>{


@Override
public void onPreExecute(){
// show progress dialog or something if you want.
}

@Override
protected ArrayList<Object> doInBackground(Void... params) {
try{
ArrayList<Object> a=new ArrayList<Object>();
a.add(WebService1()); // WebService1 returns the data that you want
a.add(WebService2()); // WebService1 returns the data that you want
a.add(WebService2()); // WebService1 returns the data that you want

return a
d.cancel();
}
return null;
}

@Override
protected void onPostExecute(ArrayList<Object> param){
// stop loading icon or loading dialog...

// Manage the content of the arrayList like you need.

}

} //WSTask

关于单个AsyncTask中的Android多个Web服务调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12799796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com