php - Android Volley Post String and Get JSONArray -


how can post string php web server , jsonarray in response using volley library in android. following code in want response. how can post string , jsonarray in response using function

see code if works

jsonarrayrequest(method.post,config.view_profile_url,                 new response.listener<jsonarray>() {                     @override                     public void onresponse(jsonarray response) {                         //calling method parse json array                         parsedata(response);                     }                 },                 new response.errorlistener() {                     @override                     public void onerrorresponse(volleyerror arg0) {                         // todo auto-generated method stub                      }                 }){              protected map<string, string> getparams() throws authfailureerror {                 map<string, string> params = new hashmap<>();                 params.put("user_name", user);                 return params;             }         };           mysingleton.getinstance(this).addtorequestqueue(jsonarrayrequest);         } 

//and receiving @ server like

$username =$_post["user_name"];

use getparams() method in request send parameter server
can set string body after url:

  jsonarrayrequest request = new jsonarrayrequest(request.method.post, "url", "you can send string here body", new response.listener<jsonarray>() {         @override         public void onresponse(jsonarray response) {             // parse json array          }     }, new response.errorlistener() {         @override         public void onerrorresponse(volleyerror error) {             // handle errors here         }     }) {         @override         protected map<string, string> getparams() {   // send parameters here             map<string, string> params = new hashmap<>();             params.put("key1", "value1");             // add other parameters             return params;         }     };     mysingleton.getinstance(this).addtorequestqueue(request); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -