【Android网络请求】如何使用Volley发送POST请求
2016-07-03 15:59
645 查看
如何使用Volley发送POST请求
try { RequestQueue mQueue = Volley.newRequestQueue(App.CONTEXT); JSONObject json = new JSONObject(); json.put("name", "zhangsan"); json.put("pwd", "123456"); JsonObjectRequest stringRequest = new JsonObjectRequest( Request.Method.POST, //POST请求 "http://192.168.2.2:8080/YourProject/loginServlet", //请求的URL json, //请求的JSON (JSONObject response) -> //取得返回的JSON数据 Log.d("JsonObjectRequest", response.toString()), (VolleyError error) -> //调用失败的操作 Log.e("TAG", error.getMessage(), error)); mQueue.add(stringRequest); mQueue.start(); } catch (JSONException e) { e.printStackTrace(); }
相关文章推荐
- 读书笔记-java网络编程-3线程-java线程概述
- 网络攻防
- HTML5+规范:Downloader(管理网络文件下载任务)
- TCP /IP 协议- 链路层
- 【FFMPEG】网络流媒体协议
- linux minimal安装方式nat网络配置
- 【JAVA】通过HttpURLConnection 上传和下载文件(二)
- TCP /IP 协议-简介
- TCP的三次握手和四次挥手
- [线性规划与网络流24题] 网络流常见模型
- TCP /IP 协议-(传输层)UDP协议
- python学习之路-9 socket网络编程
- http://www.cnblogs.com/saqhybj/p/4723345.html
- http://www.cnblogs.com/jiligalaer/p/4097429.html
- TCP /IP 协议- (网络层)ARP、 RARP、ICMP、IGMP协议
- CCNA+NP学习笔记—交换网络篇
- CCNA+NP学习笔记—交换网络篇
- android网络框架Retrofit使用记录
- 在线答题系统(适合党政军和院校使用的网络竞答系统)
- JavaScript笔记整理 —— XMLHttpRequest对象