OkHttpClient 的get使用

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


版权声明:本文为yangchao00xiao原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。