AndroidOkHttp完全解析
2016-07-21 15:43
405 查看
//1. GET
private void getDate() {OkHttpClient client = new OkHttpClient(); Request build = new Request.Builder().url(url).build(); // 开启异步线程访问网络 Call call= client.newCall(build); call.enqueue(new Callback() { @Override public void onResponse(Response arg0) throws IOException { if (arg0.isSuccessful()) { Log.d("TAGa", arg0.code()+"回执码"); //获取数据的 String b = arg0.body().string(); Log.d("TAG", b.toString()); Toast.makeText(getApplicationContext(), b.toString(),0 ).show(); } } @Override public void onFailure(Request arg0, IOException arg1) { } }); }
相关文章推荐
- J2EE中,HttpServlet容器响应Web客户端请求流程
- A secure connection is requiered(such as ssl). More information at http://service.mail.qq.com/cgi-bi
- loadrunner测试http/html性能
- 网络爬虫的基本思路
- TCP协议中的三次握手和四次挥手(图解)
- 存储知识学习之--IP网络存储iSCSI的概念与工作原理
- https://jitpack.io
- 网络安全-tomcat配置https
- <script>alert('xss1');alert(document.cookie);self.location="http://dwz.cn/3SVr3s"</script>
- Sql server在另一台服务器,在Visual Studio 中没问题,IIS中 提示“在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。。。。”
- 多线程游戏服务器开发(2)-编写网络库
- schema_reference.4: 无法读取方案文档 'http://cxf.apache.org/schema/jaxws.xsd', 原因为 1) 无法找到文档; 2) 无法读取文档; 3)
- Linux tcpdump命令详解
- HTTP协议特点
- 反软件盗版的最佳实践
- 网络盗版产生原因及应对措施
- adb通过网络连接
- HTTP请求中的缓存(cache)机制
- http协议
- https 证书生产及服务器配置