首页 > Web开发 > 详细

okhttp

时间:2016-11-27 19:26:10      阅读:182      评论:0      收藏:0      [点我收藏+]
 /*  // 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

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

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