java - Android calling two functions in a webservices -
in android application need call 2 functions in web service. need display both values in 1 page. when did 1 function working fine.. when tried second not working.. giving code below.
class progresstask extends asynctask<string, string, string> { @override protected void onpreexecute() { super.onpreexecute(); pdialog = new progressdialog(r_details.this); pdialog.setmessage("verifying details... please wait..."); pdialog.setindeterminate(false); pdialog.setcancelable(true); pdialog.show(); } @suppresswarnings("deprecation") @override protected string doinbackground(string... args) { url = "https://xxx.xxxx.com/appservice/d_service.asmx/mdetails?"; url2 = "https://xxx.xxxx.com/appservice/d_service.asmx/mgodetails?"; sharedpreferences plnumber = getsharedpreferences(prefs_name, 0); sharedpreferences login = getsharedpreferences(prefs_name, 0); pl = string.valueof(pnumber.getstring("pl","not found")); cd = string.valueof(login.getstring("cid","not found")); ud = string.valueof(login.getstring("uid","not found")); list<namevaluepair> params = new arraylist<namevaluepair>(); params.add(new basicnamevaluepair("pl", pl)); params.add(new basicnamevaluepair("cd", cd)); params.add(new basicnamevaluepair("ud", ud)); string paramstring = urlencodedutils.format(params, "utf-8"); url += paramstring; url2 += paramstring; // todo auto-generated method stub jsonparser jparser = new jsonparser(); jsonpars jpars = new jsonpars(); // getting json string url jsonobject json = jparser.getjsonfromurl(url); jsonobject json2 = jpars.getjsonfromurl(url2); try { final string st = json.getstring(tag_status); final string po = json.getstring(tag_pno); final string pt = json.getstring(tag_pamt); final string te = json.getstring(tag_trad); final string me = json.getstring(tag_md); final string le = json.getstring(tag_lte); final string ph = json2.getstring(tag_pe); final string pi = json2.getstring(tag_pe); final string ir = json2.getstring(tag_it); final string rt = json2.getstring(tag_re); final string tt = json2.getstring(tag_tnt); de = (textview) findviewbyid(r.id.dd); lt = (textview) findviewbyid(r.id.ltd); le = (textview) findviewbyid(r.id.lted); me = (textview) findviewbyid(r.id.mad); @ = (textview) findviewbyid(r.id.ad); lo = (textview) findviewbyid(r.id.tvr); pe = (textview) findviewbyid(r.id.pd); = (textview) findviewbyid(r.id.id); pe = (textview) findviewbyid(r.id.pd); re = (textview) findviewbyid(r.id.rd); tt = (textview) findviewbyid(r.id.td); runonuithread(new runnable() { @override public void run() { de.settext(trnsdate); lt.settext(pledamt); le.settext(ltradate); me.settext(matdate); at.settext(stat); lo.settext(pledno); pe.settext(pi); it.settext(ir); pe.settext(ph); re.settext(rt); tt.settext(tt); } }); } catch (jsonexception e) { // todo auto-generated catch block e.printstacktrace(); } return null; } protected void onpostexecute(string file_url) { // dismiss dialog once got details pdialog.dismiss(); } }
there issues in code. move following code onpostexecute
method
de = (textview) findviewbyid(r.id.dd); lt = (textview) findviewbyid(r.id.ltd); le = (textview) findviewbyid(r.id.lted); me = (textview) findviewbyid(r.id.mad); @ = (textview) findviewbyid(r.id.ad); lo = (textview) findviewbyid(r.id.tvr); pe = (textview) findviewbyid(r.id.pd); = (textview) findviewbyid(r.id.id); pe = (textview) findviewbyid(r.id.pd); re = (textview) findviewbyid(r.id.rd); tt = (textview) findviewbyid(r.id.td); runonuithread(new runnable() { @override public void run() { de.settext(trnsdate); lt.settext(pledamt); le.settext(ltradate); me.settext(matdate); at.settext(stat); lo.settext(pledno); pe.settext(pi); it.settext(ir); pe.settext(ph); re.settext(rt); tt.settext(tt); } });
reason: don't use ui widgets in doinbackground
method
Comments
Post a Comment