Doasktask = new Runnable () { @Override public void Run () { Todo HTTP request is made here. Network requests related operations Ggname = Etname.gettext (). toString (); Ggworkid = Etworkid.gettext (). toString (); Ggcallid = Etcallid.gettext (). toString (); String BaseURL = Confiddatas.askbaseurl; String askstr = "Name=" + ggname + "&callid=" + ggcallid + "&workid=" + ggworkid; String result = null; HttpGet httpget = new HttpGet (BaseURL + askstr); The second step is to use the Execute method to send an HTTP GET request and return the HttpResponse object HttpResponse HttpResponse = null; try { HttpResponse = new Defaulthttpclient (). Execute (httpget); } catch (Clientprotocolexception e) { TODO auto-generated Catch block E.printstacktrace (); } catch (IOException e) { TODO auto-generated Catch block E.printstacktrace (); } Message msg = new Message (); Bundle data = new bundle (); if (Httpresponse.getstatusline (). Getstatuscode () = = 200) { The third step is to use the GetEntity method to return the result try { result = Entityutils.tostring (httpresponse.getentity ()); Data.putstring ("value", result); Data.putstring ("Result", "isOK"); Msg.setdata (data); Handler.sendmessage (msg); } catch (ParseException e) { E.printstacktrace (); } catch (IOException e) { E.printstacktrace (); } } else {//error Data.putstring ("Value", ""); Data.putstring ("Result", "iserr"); Msg.setdata (data); Handler.sendmessage (msg); } } }; |