android怎么okhttp用get请求
1个回答
展开全部
直接上代码:
OkHttpClient client = new OkHttpClient();
String run(String url) throws IOException {
Request request = new Request.Builder().url(url).build();
Response response = client.newCall(request).execute(); if (response.isSuccessful()) { return response.body().string();
} else { throw new IOException("Unexpected code " + response);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询