android - Showing ProgressDialog in AsyncTask only for specific parameters -


i'm implementing asynctask, calls wcf service methods in doinbackground method.

the wcf method name parameter doinbackground method.

i want progress dialog show specific methods name sent doinbackground.

my porgressdialog setting set in onpreexecute methods.

any way make progressdialog appear specific doinbackground parameter (wcf method name)

public class wcfhelper extends asynctask<object, void, string[]>{  private static final string namespace = "http://tempuri.org/"; private static final string url = "http://url"; final progressdialog pd; public context ctx;    public wcfhelper(context _ctx) {   this.ctx = _ctx;     pd = new progressdialog(_ctx); }  @override protected void onpreexecute() {      pd.setprogressstyle(progressdialog.style_spinner);     pd.setmessage("login...");     pd.setindeterminate(true);     pd.setcancelable(false);     pd.show();  }  @override protected string[] doinbackground(object... params) {     string wcfmethod = (string)params[0];     map<string,object> parameterargs = (map<string,object>)params[1];     boolean isarr = (boolean)params[2];      string [] fail = {"fail"};      string soap_action = "http://tempuri.org/iservice1/"+wcfmethod;      string method_name = wcfmethod;     try {         soapobject request = new soapobject(namespace, method_name);                 for(map.entry<string,object> entry: parameterargs.entryset())                request.addproperty(entry.getkey().tostring(), entry.getvalue().tostring());                   soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11);          envelope.dotnet = true;         envelope.setoutputsoapobject(request);         httptransportse androidhttptransport = new httptransportse(url);         androidhttptransport.call(soap_action, envelope);          if(!isarr)         {             soapprimitive result = (soapprimitive)envelope.getresponse();                            string[] toreturn = new string[1];              toreturn[0] = result.tostring();             return toreturn;         }         else{             envelope.implicittypes = true ;              soapobject listdataset = (soapobject) envelope.bodyin;                       int numofstrings = ((soapobject)listdataset.getproperty(0)).getpropertycount();             string[] toreturn = new string[numofstrings];                  ( int = 0 ; <numofstrings; i++) {                   toreturn[i] = ((soapobject)listdataset.getproperty(0)).getproperty(i).tostring();                }               return toreturn;             }         }     catch (exception e) {         return fail;       }  }   protected void onpostexecute(string res) {         // todo: check this.exception          // todo: feed              if(this.pd.isshowing())             pd.dismiss();       } 

as can see 1 of params doinbackground wcf method name. want progressdialog show specific wcf methods (received parameter)

you can create own custom constructor of asynctask transfer necessary parameter handling progress dialog.

private class mytask extends asynctask<void, void, void> {       public mytask(boolean showprogress){      ....     }      .... } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -