How to Connect Android Device with web serve using AsyncTask -


i have asynctask.i need connect device web server.need send json arry , receive json array. can use httpurlconnection ? or httpclient. httpclient support latest versions of android?

  class background_thread extends asynctask<jsonarray, void, boolean> {     protected boolean doinbackground(jsonarray... params) {          //connect server side php script         string ur = "127.0.0.1/abc/index.php";         try {             url url = new url(ur);             try {                  httpurlconnection conn = (httpurlconnection) url.openconnection();                 json_array=json_encode();                 conn.setdooutput(true);                 conn.setchunkedstreamingmode(0);                 outputstream out = new bufferedoutputstream(conn.getoutputstream());                 writestream(out);                 } catch (ioexception e) {                 e.printstacktrace();             }          } catch (malformedurlexception e) {             e.printstacktrace();         }            return true;      } 

you should use google's own volley library make network calls , handle response data in model classes. modular approach. refer this link official documentation.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -