post - Data not getting posted to server while using Volley library in android -
i trying post
jsonobject
server using volley
library in android. uncertainty getparams
method not beingness called , info not getting posted. can guide me step step going wrong. codes follows:
case r.id.bt_search: seek { jobj.put("fromdate", "04-10-2014"); jobj.put("todate", "04-11-2014"); jobj.put("billnumber", bill); jobj.put("status", "notclosed"); jobj.put("ordertype", "1,2,3" /* ordertype */); log.i("json info on clicking search", "" + jobj); makejsonobjreq(jobj); } grab (jsonexception e) { // todo auto-generated grab block e.printstacktrace(); } break; private void makejsonobjreq(final jsonobject jobj) { // todo auto-generated method stub requestqueue rq = volley.newrequestqueue(this); jsonobjectrequest jsonobjreq = new jsonobjectrequest( method.post, "myurl", null, new response.listener<jsonobject>() { @override public void onresponse(jsonobject arg0) { // todo auto-generated method stub log.d("server response", arg0.tostring()); seek { (int = 0; < arg0.length(); i++) { } } grab (exception e) { } } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror arg0) { // todo auto-generated method stub volleylog.d("error msg server", "error: " + arg0.getmessage()); } }) { @override protected map<string, string> getparams() throws authfailureerror { // todo auto-generated method stub map<string, string> params = new hashmap<string, string>(); params.put("data", jobj.tostring()); //return params; homecoming super.getparams(); } @override public map<string, string> getheaders() throws authfailureerror { // todo auto-generated method stub homecoming super.getheaders(); } }; com.cashier.volley_helper.appcontroller.getinstance() .addtorequestqueue(jsonobjreq); rq.add(jsonobjreq); };
you have modify getparams() method
private void makejsonobjreq(final jsonobject jobj) { // todo auto-generated method stub requestqueue rq = volley.newrequestqueue(this); jsonobjectrequest jsonobjreq = new jsonobjectrequest( method.post, "myurl", null, new response.listener<jsonobject>() { @override public void onresponse(jsonobject arg0) { // todo auto-generated method stub log.d("server response", arg0.tostring()); seek { (int = 0; < arg0.length(); i++) { } } grab (exception e) { } } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror arg0) { // todo auto-generated method stub volleylog.d("error msg server", "error: " + arg0.getmessage()); } }) { @override protected map<string, string> getparams() throws authfailureerror { // todo auto-generated method stub map<string, string> params = super.getparams(); if( params==null) params =new hashmap<string, string>(); params.put("data", jobj.tostring()); homecoming params; } @override public map<string, string> getheaders() throws authfailureerror { // todo auto-generated method stub homecoming super.getheaders(); } }; com.cashier.volley_helper.appcontroller.getinstance() .addtorequestqueue(jsonobjreq); rq.add(jsonobjreq); }
android post android-volley
No comments:
Post a Comment