Android : Send Int in HashMap with Volley

on Saturday, December 13, 2014


i have implemented this answer - http://stackoverflow.com/a/19945676/4281848 in my code and it works great, however i am currently trying to send an integer with the hashmap and it is of course saying that it can only send strings, how could i change this to allow sending integers as well as strings


Here is my current code



HashMap<String, Integer> params = new HashMap<String, Integer>();
params.put("uid", userId);

CustomRequest jsObjRequest = new CustomRequest(Request.Method.POST,
jsonUrl,params,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
VolleyLog.v("Response:%n %s", response.toString(4));
int code = response.getInt("code");
String message = response.getString("message");

} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.e("Error: ", error.getMessage());
}
});

AppController.getInstance().addToRequestQueue(jsObjRequest, tag_json_obj);


Thanks for any and all help


0 comments:

Post a Comment