如何在此代码中设置超时时间?
okhttp3.OkHttpClient client = new okhttp3.OkHttpClient();
okhttp3.Request request = new okhttp3.Request.Builder()
.url(url)
.get()
.build();
Call call = client.newCall(request);
call.enqueue(callback);
谢谢。
答案 0 :(得分:2)
client = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS).build()