首页 > Web开发 > 详细

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

时间:2014-06-23 06:00:21      阅读:487      评论:0      收藏:0      [点我收藏+]

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.Listener<JSONObject>() { ... });

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,
        Listener<JSONObject> listener, ErrorListener errorListener) {
    super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener,
                errorListener);
}
 

Google Volley: How to send a POST request with Json data?,布布扣,bubuko.com

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!