android - How to reduce app data usage? -
i have android app sends http post every 5 minutes gps data. size of post (including header , body) less 1kb. response less 1kb. however, i'm noticing app consuming 40kb every post. after experimenting , eliminating other factors contribute data usage, i'm post thing that's consuming 40kb. normal http post consume data? or way android os handles network calls adds overhead? below code i'm using post. i'm using apache http library.
public string callwebmethod( context pocontext, string psresturl, string psmethodnamewithgetparameters, jsonobject pspostparameters, long pntimeout) { string shttpposturl = ""; stringentity paramentity = null; httpclient httpclient = new defaulthttpclient(); httppost httppost = null; httpresponse httpresponse = null; string sconvertedresponse = ""; httpparams httpparams = new basichttpparams(); try { // set entity paramentity = new stringentity(pspostparameters.tostring()); paramentity.setcontenttype(new basicheader(http.content_type, "application/json")); // send post shttpposturl = psresturl + "/" + psmethodnamewithgetparameters; httpconnectionparams.setconnectiontimeout(httpparams, (int) pntimeout); httpconnectionparams.setsotimeout(httpparams, (int) pntimeout); httppost = new httppost(shttpposturl); httppost.setparams(httpparams); httppost.setheader("content-type", "application/json"); httppost.setheader("accept", "application/xml"); httppost.setentity(paramentity); httpresponse = httpclient.execute(httppost); // response if (httpresponse == null) { log.w(tag, "no http response"); return null; } sconvertedresponse = entityutils.tostring(httpresponse.getentity()); return sconvertedresponse; } catch (exception ex) { ex.printstacktrace(); return null; } }
Comments
Post a Comment