android - Encoding HttpURLConnection Parameter work in marshmallow but not in jellybean -


 public static string getjson(string url, int timeout) {     httpurlconnection c = null;     try {         url = url.replace("%20", " ");         url u = new url(url);         uri uri = new uri(u.getprotocol(), u.getuserinfo(), u.gethost(),  u.getport(), u.getpath(), u.getquery(), u.getref());         u = uri.tourl();         c = (httpurlconnection) u.openconnection();         c.setdooutput(true);         c.setdoinput(true);         c.setinstancefollowredirects(false);         c.setrequestmethod("post");         c.setrequestproperty("accept", "application/x-www-form-urlencoded;charset=utf-8");         c.setrequestproperty("content-type", "application/x-www-form-urlencoded");         c.setrequestproperty("charset", "utf-8");         c.setrequestproperty("content-length", "0");         c.setrequestproperty("accept-encoding", "identity");          c.setusecaches(false);         c.setallowuserinteraction(false);         c.setconnecttimeout(timeout);         c.setreadtimeout(timeout);         c.connect();         int status = c.getresponsecode();         switch (status) {             case 200:             case 201:                 bufferedreader br = new bufferedreader(new inputstreamreader(c.getinputstream(), "utf-8"));                 stringbuilder sb = new stringbuilder();                 string line;                 while ((line = br.readline()) != null) {                     sb.append(line + "\n");                 }                 br.close();                 return sb.tostring();         }     } catch (exception ex) {         return "error connection";     }      return "error connection"; } 

when test on marshmallow parameters spaces or in arabic language encoding , decoding when test on jellybean encoding not work please me fix probelm


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -