OkHttpClient 的get使用

来源:互联网 发布:python 遗传算法 编辑:程序博客网 时间:2024/06/06 16:42
OkHttpClient okHttpClient =new OkHttpClient();Request builder = new Request.Builder()        .url("https://www.zhaoapi.cn/ad/getAd")        .build();Call call = okHttpClient.newCall( builder);call.enqueue(new Callback() {    @Override    public void onFailure(Request request, IOException e) {    }    @Override    public void onResponse(Response response) throws IOException {        if (response.isSuccessful())        {            String string = response.body().string();            Log.d("-------------",string);        }    }});

原创粉丝点击