如何从单个Asynctask调用多个Web服务调用,在此先感谢。
答案 0 :(得分:2)
他们是同步的吗?然后拨打第一个,第二个......
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