0

I am working on AsynTask, single url call from AsynTask fine but i want to call two web services one after other in AsyncTask, can you please send some code or idea.

My code:

public class GetInstructionItems extends AsyncTask<String, Void, Boolean> {

    public ProgressDialog myProgressDialog = null;
    private Boolean authenticationResult = false;
    private String LOG = SurgicalHistoryAsynTask.class.getName(); 
    private String responseString = "getInstructionItemsResult";
    JSONObject totalResult;

    protected Boolean doInBackground(String... params) 
    {
        return getRespose(params[0]);
    }

    protected void onPostExecute(Boolean result) {

        myProgressDialog.dismiss();
        if (result) 
        {
            Log.d(LOG, "Response ::result "+result);

        }else{

            showAlertMsg(getString(R.string.response_fail));
        }
    }
    protected void onPreExecute() {

        if (!authenticationResult) {
            myProgressDialog = new ProgressDialog(getActivity());
            myProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            myProgressDialog.setMessage("loading...");
            myProgressDialog.setCancelable(false);
            myProgressDialog.setProgress(100);
            myProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            myProgressDialog.show();
        }
    }

    private boolean getRespose(String inputUrl){


        return true;
    }
}
HitOdessit
  • 7,198
  • 4
  • 36
  • 59
Ravikumar11
  • 429
  • 2
  • 9
  • 15

1 Answers1

0
protected Boolean doInBackground(String... params) 
{
    getRespose(params[0]);
    getRespose(params[1]);
    getRespose(params[2]);
    return true;
}

OR

class Responces
{
     boolean r1, r2, r3;
}


protected Responces doInBackground(String... params) 
{
    Responces r = new Responces();

    r.r1 = getRespose(params[0]);
    r.r2 = getRespose(params[1]);
    r.r3 = getRespose(params[2]);
    return r;
}
Nik
  • 7,114
  • 8
  • 51
  • 75