Google Volley: How to send a POST request with Json data?

2020-12-13 16:26

阅读:208

标签:android   class   blog   code   java   http   

sonObjectRequest actuallyaccepts JSONObject as body.

From http://arnab.ch/blog/2013/08/asynchronous-http-requests-in-android-using-volley/

final String url = "some/url";
final JSONObject jsonBody = /* ... */;

new JsonObjectRequest(url, jsonBody, new Response.ListenerJSONObject>() { ... });

Here is the offical code and javadoc (@param jsonRequest):

/**
 * Creates a new request.
 * @param method the HTTP method to use
 * @param url URL to fetch the JSON from
 * @param jsonRequest A {@link JSONObject} to post with the request. Null is allowed and
 *   indicates no parameters will be posted along with request.
 * @param listener Listener to receive the JSON response
 * @param errorListener Error listener, or null to ignore errors.
 */
public JsonObjectRequest(int method, String url, JSONObject jsonRequest,
        ListenerJSONObject> listener, ErrorListener errorListener) {
    super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener,
                errorListener);
}
 

Google Volley: How to send a POST request with Json data?,搜素材,soscw.com

Google Volley: How to send a POST request with Json data?

标签:android   class   blog   code   java   http   

原文地址:http://www.cnblogs.com/savagemorgan/p/3799844.html


评论


亲,登录后才可以留言!