Created
June 13, 2014 15:51
-
-
Save EvlinLee/4db00f11171c0292bcdb to your computer and use it in GitHub Desktop.
android volley jsonarray post method with params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JsonArrayPostRequest extends Request<JSONArray>{ | |
private Map<String,String> mParam; | |
private Listener<JSONArray> mListener; | |
public JsonArrayPostRequest(String url,Listener<JSONArray> listener, ErrorListener errorListener,Map param) { | |
super(Request.Method.POST, url, errorListener); | |
mListener=listener; | |
mParam=param; | |
} | |
@Override | |
protected Map<String, String> getParams() throws AuthFailureError { | |
return mParam; | |
} | |
@Override | |
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) { | |
try { | |
String jsonString = | |
new String(response.data, HttpHeaderParser.parseCharset(response.headers)); | |
return Response.success(new JSONArray(jsonString), | |
HttpHeaderParser.parseCacheHeaders(response)); | |
} catch (UnsupportedEncodingException e) { | |
return Response.error(new ParseError(e)); | |
} catch (JSONException je) { | |
return Response.error(new ParseError(je)); | |
} | |
} | |
@Override | |
protected void deliverResponse(JSONArray response) { | |
mListener.onResponse(response); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have jsonArrayRequest = new JsonArrayRequest(GET_JSON_DATA_HTTP_URL, in class RiwayatActivity, and your code must create new class for send a post.. so how to I call that new class in RiwayatActivity?