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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章