android - onPostExecute() method not being executed -
i have 2 web service methods being called in asynctask. first 1 being called second web service method not called. idea how call second method after first?
asynctask code
public class transaction extends asynctask<string,void,string> { private string finalbalance1 = "", price1 = "", pname = "", pnric = "", pclass = "", sno = ""; public transaction(string price1, string pname, string pnric, string pclass, string sno, string finalbalance1) { super(); this.finalbalance1 = double.tostring(finalbalance); this.price1 = double.tostring(sprice); this.pname = sra.studentname; this.pnric = sra.studentnric; this.pclass = sra.studentclass; this.sno = logger.stallno; } @override protected string doinbackground (string...url) { string result = ""; httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://152.226.152.175/nco/webservice.asmx/insertstudenttransaction"); try { list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(5); namevaluepairs.add(new basicnamevaluepair("nric", pnric)); namevaluepairs.add(new basicnamevaluepair("name", pname)); namevaluepairs.add(new basicnamevaluepair("class", pclass)); namevaluepairs.add(new basicnamevaluepair("stallno", sno)); namevaluepairs.add(new basicnamevaluepair("amountspent", price1)); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); inputstream in = entity.getcontent(); bufferedreader reader = new bufferedreader(new inputstreamreader(in, "utf-8"), 8); stringbuilder sb = new stringbuilder(); string line = null; while ((line = reader.readline()) != null) { result = line; } } catch (clientprotocolexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } return result; } protected void onpostexecute (string result) { if(result != null) { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://152.226.152.175/nco/webservice.asmx/updateparticulars"); try { list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(4); namevaluepairs.add(new basicnamevaluepair("nric", pnric)); namevaluepairs.add(new basicnamevaluepair("fixedamount", finalbalance1)); namevaluepairs.add(new basicnamevaluepair("name", pname)); namevaluepairs.add(new basicnamevaluepair("class", pclass)); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); inputstream in = entity.getcontent(); bufferedreader reader = new bufferedreader(new inputstreamreader(in, "utf-8"), 8); stringbuilder sb = new stringbuilder(); string line = null; while ((line = reader.readline()) != null) { system.out.println(line); } } catch (clientprotocolexception e) { e.printstacktrace(); }catch (ioexception e) { e.printstacktrace(); } } } } }
@override missing before onpostexecute(string result), , check result getting null
Comments
Post a Comment