码迷,mamicode.com
首页 > Web开发 > 详细

okhttp

时间:2016-11-27 19:28:42      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:www   ack   fail   callback   ble   client   public   exception   set   

 /*  // final Request request = new Request.Builder().url("https://localhost:8080/zb.json").build();//这个地址拿不到数据
final Request request = new Request.Builder().url("http://202.192.134.11:8080/zb.json").build();
// final Request request = new Request.Builder().url("https://www.baidu.com").build();
OkHttpClient client = new OkHttpClient();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("TAG","okhttp获取数据失败");
}

*//**
* 此时还在非UI线程中
* @param call
* @param response
* @throws IOException
*//*
@Override
public void onResponse(Call call, Response response) throws IOException {
final String res = response.body().string();
Log.e("TAG",res);
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.e("TAG", res);
Log.e("TAG", "倪伟金");
version_textView.setText(res);
}
});
}
});
*/

okhttp

标签:www   ack   fail   callback   ble   client   public   exception   set   

原文地址:http://www.cnblogs.com/princenwj/p/6106826.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!