OkHttpClient带多个参数的get请求

token放在Header里面,通过addHeader方法添加,其他的参数全部拼接在URL里面,

get的多个参数放在URL后面就行了,post的多个参数需要放在RequestBody里面

String urlString = URLUtil.url_MainHomePage_Dynamics+"?page="+page+"&compatible=isNewVersion";

OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().addHeader("Authorization", "Bearer " + Account.user_token).url(urlString).get().build();
client.newCall(request).enqueue(new Callback() {

     public void onFailure(Request request, IOException e) {

    }
    public void onResponse(Response response) throws IOException {

     }
});

你可能感兴趣的:(安卓知识点)