//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) {
}
});
}