//okHttp依赖 //implementation 'com.squareup.okhttp:okhttp:2.0.0' public class HttpHelper { private final int FAILURE_CODE=1001;//失败 private final int SUCCESS_CODE=1000;//成功 private HttpListener listener; //get请求 public HttpHelper get(String url){ OkHttpClient okHttpClient=new OkHttpClient(); Request request=new Request.Builder() .url(url) .build(); try { doHttp(okHttpClient, request); } catch (IOException e) { e.printStackTrace(); } return this; } private void doHttp(OkHttpClient okHttpClient, Request request) throws IOException { final Message message=Message.obtain(); okHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) {