android - volley how to parse params to JsonObjectRequest getParams does not work -
as old version
of volley.jar
. pass params
following method:
@override public byte[] getbody() { if (params != null && params.size() > 0) { return encodeparameters(params, getparamsencoding()); } return null; }
but need update volley, , find method(encodeparameters()) changed private.
i found override method of getparams()
, did not work me. method getbody
of jsonobjectrequest
following:
public byte[] getbody() { try { return mrequestbody == null ? null : mrequestbody.getbytes(protocol_charset); } catch (unsupportedencodingexception uee) { volleylog.wtf("unsupported encoding while trying bytes of %s using %s", mrequestbody, protocol_charset); return null; } }
getparams()
never called. cannot pass params
now.
i tried pass params
in construct method has jsonobject
param, did not work either.
hope i'm understanding correctly.
an easier way pass params volley be:
string url = "some/url"; map<string, object> jsonparams = new hashmap<>(); jsonparams.put("someparam", getsomeparamobject()); jsonobjectrequest request = new jsonobjectrequest(request.method.post, url, new jsonobject(jsonparams), new response.listener<jsonobject>() { @override public void onresponse(jsonobject response) { //do magic... } }
for encoding issue, see if so question helps.
hope helps.
Comments
Post a Comment