Reputation: 449
How to call multiple web services call from single Asynctask,Thanks in Advance.
Upvotes: 2
Views: 1372
Reputation: 1156
Are they synchronous? Then call the first, the second...
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
Upvotes: 2