How to add list into params of volley Android?
Asked Answered
C

2

1

Please help me how can i add a list in param of volley android like this

@Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("UGUID", UGUID);
            params.put("INAME", list);
            return params;
        }

It is working for sample string but its not work for list of string

Corbeil answered 6/7, 2018 at 8:39 Comment(1)
Possible duplicate of Android Volley send Array as a param along with StringSlump
C
1

Try like this

@Override protected Map<String, Object> getParams() throws AuthFailureError {
    Map<String, Object> params = new HashMap<>();
    params.put("UGUID", UGUID);
    params.put("INAME", list);
    params.put("ARRAY_NAME",yourarray);
    return params;
}
Capparidaceous answered 6/7, 2018 at 10:0 Comment(1)
JSONArray words_ar = new JSONArray(); JSONObject jsonObject= new JSONObject(); try { jsonObject.put("INAME","943caf91b4e44313a94a308001c230c5.jpg"); words_ar.put(jsonObject); jsonObject.put("INAME","b6ecbcb4a6a64128ba56ec01cb7ffe17.png"); words_ar.put(jsonObject); }catch (JSONException e){ e.printStackTrace(); } Map<String, String> params = new HashMap<>(); params.put("UGUID", UGUID); params.put("INAME", words_ar.toString());Corbeil
O
0

if you want to send list to server you can create a json array and convert it to string and send it to server

@Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("UGUID", UGUID);
            params.put("INAME", list);
            params.put("your_key_d_for_array",yourarray.tostring());
            return params;
        }
Orthopedic answered 6/7, 2018 at 9:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.