OkhttpRequest

public class OkhttpRequest {
public void sendPostRequest(HashMap map, String apiurl, okhttp3.Callback callback){
OkHttpClient client=new OkHttpClient();
FormBody.Builder builder=new FormBody.Builder();
Set set=map.keySet();
Iterator iterator =set.iterator();
while (iterator.hasNext()){
String key=iterator.next();
String value=map.get(key);
builder.add(key,value);
}
FormBody formBody=builder.build();
Request request=new Request.Builder().url(apiurl).post(formBody).build();
Call call=client.newCall(request);
call.enqueue(callback);
}
}

你可能感兴趣的:(android)