Using AsyncTask for an HTTP GET on android causes a long delay in sending data -


i using asynctask perform http on android. causes long delay in sending data url. there way fix or approach can used?

here code: class requesttask extends asynctask{

    @override     protected string doinbackground(string... uri) {         httpclient httpclient = new defaulthttpclient();         httpresponse response;         string responsestring = null;          httpparams httpparameters = httpclient.getparams();         httpconnectionparams.settcpnodelay(httpparameters, true);          try {             response = httpclient.execute(new httpget(uri[0]));             statusline statusline = response.getstatusline();             if(statusline.getstatuscode() == httpstatus.sc_ok){                 bytearrayoutputstream out = new bytearrayoutputstream();                 response.getentity().writeto(out);                 responsestring = out.tostring();                 out.close();             } else{                 //closes connection.                 response.getentity().getcontent().close();                 throw new ioexception(statusline.getreasonphrase());             }         } catch (clientprotocolexception e) {             //todo handle problems..         } catch (ioexception e) {             //todo handle problems..         }         return responsestring;     }      @override     protected void onpostexecute(string result) {         super.onpostexecute(result);         //do response..     } } 

and here call:

new requesttask().execute("http://10.10.10.211:9081/?modelname=model1&sourcedata=" + values[1]);

i recommend use volley approach. use in projects , i've never gotten problem that.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -