Android Wifi connection drops after using my app -


spent whole day looking @ piece of code , still couldn't figure out why wifi connections used app drop after exit app (press home, btns, etc.)

public jsonobject getjsonfromurl(string url, list<namevaluepair> params, boolean isuploadingfile, multipartentity entity) throws exception {          // initialize         httpentity httpentity = null;         httppost httppost = null;         = null; jobj = null; json = "";          // making http request         try {             httpparams httpparameters = new basichttpparams();             // set timeout in milliseconds until connection established.             // default value zero, means timeout not used.             int timeoutconnection = 10000;             httpconnectionparams.setconnectiontimeout(httpparameters, timeoutconnection);             // set default socket timeout (so_timeout)             // in milliseconds timeout waiting data.             int timeoutsocket = 10000;             httpconnectionparams.setsotimeout(httpparameters, timeoutsocket);              // defaulthttpclient             defaulthttpclient httpclient = new defaulthttpclient(httpparameters);             httppost = new httppost(url);             if (isuploadingfile)                 httppost.setentity(entity);             else                 httppost.setentity(new urlencodedformentity(params,"utf-8"));              httpresponse httpresponse = httpclient.execute(httppost);             httpentity = httpresponse.getentity();          } catch (exception e) {             log.e("exceptions", e.tostring());             return jobj;         }          if (httpentity != null) {             = httpentity.getcontent();             // read server response             try {                 bufferedreader reader = new bufferedreader(new inputstreamreader(is, "utf-8"));                 stringbuilder sb = new stringbuilder();                 string line = null;                 while ((line = reader.readline()) != null) {                     sb.append(line + "\n");                 }                  is.close();                 reader.close();                 json = sb.tostring();                  //log.e("json", json); // !!! comment line release !!!             } catch (exception e) {                 log.e("buffer error", "error converting result " + e.tostring());             } {                 try {                     if (httpentity != null)                         httpentity.consumecontent();                 } catch (exception e) {                     log.e("exceptions", e.tostring());                 }             }              // try parsing string json object             try {                 jobj = new jsonobject(json);             } catch (exception e) {                 log.e("json parser", "error parsing data " + e.tostring());             }         }          // return json object         return jobj;      } 


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -