java - RTT time not being shown android studio using asyncTask -
protected string doinbackground(pair<context,integer>... params){ // protected string doinbackground(pair<context, string>... params) { context = params[0].first; int name1 = params[0].second; httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://android- 996.appspot.com/hello"); // 10.0.2.2 localhost's ip address in android emulator try { string name= string.valueof(name1); // add name data request list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(1); namevaluepairs.add(new basicnamevaluepair("name", name)); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request long starttime = system.currenttimemillis(); httpresponse response = httpclient.execute(httppost); if (response.getstatusline().getstatuscode() == 200) { return entityutils.tostring(response.getentity()); } long elapsedtime = system.currenttimemillis() - starttime; log.d("j", "total elapsed http request/response time in milliseconds" + elapsedtime); system.out.println("total elapsed http request/response time in milliseconds: " + elapsedtime); return "error: " + response.getstatusline().getstatuscode() + " " + response.getstatusline().getreasonphrase(); } catch (clientprotocolexception e) { return e.getmessage(); } catch (ioexception e) { return e.getmessage(); }} @override protected void onpostexecute(string result) { toast.maketext(context, result, toast.length_long).show(); } }
i created app using android , @ backend using google app engine java servlet module. want calculate rtt time ,request transfer , response time . want display rtt time in logcat of android studio,but not getting output on logcat.
move below 3 lines above if
block:
long elapsedtime = system.currenttimemillis() - starttime; log.d("j", "total elapsed http request/response time in milliseconds" + elapsedtime); system.out.println("total elapsed http request/response time in milliseconds: " + elapsedtime);
so becomes this:
long starttime = system.currenttimemillis(); httpresponse response = httpclient.execute(httppost); long elapsedtime = system.currenttimemillis() - starttime; log.d("j", "total elapsed http request/response time in milliseconds" + elapsedtime); system.out.println("total elapsed http request/response time in milliseconds: " + elapsedtime); if (response.getstatusline().getstatuscode() == 200) { return entityutils.tostring(response.getentity()); }
Comments
Post a Comment