public static final String TAG="OkHttp3";
private static OkHttpClient okHttpClient;
private static Request request;
private static RequestBody builder;
/*
* okhttp get异步请求方法
* */
public static void OkHttpget(String url,Callback callss){
//创建okHttpClient
okHttpClient = new OkHttpClient();
//创建request
request = new Request.Builder().url(url).method("GET",null).build();
//
okHttpClient.newCall(request).enqueue(callss);
}
//okhttp post请求
public static void OkHttpPost(String url,String name,String pswd ,Callback call){
okHttpClient = new OkHttpClient();
builder = new FormBody.Builder()
.add("phone",name)
.add("pwd",pswd)
.build();
//创建request
request = new Request
.Builder()
.url(url)
.post(builder)
.build();
okHttpClient.newCall(request).enqueue(call);
}