OkHttpClient get请求

来源:互联网 发布:家庭媒体中心软件 编辑:程序博客网 时间:2024/06/09 18:00
//创建okHttpClient对象OkHttpClient mOkHttpClient = new OkHttpClient();//创建一个Requestfinal Request request = new Request.Builder()                .url("https://github.com/hongyangAndroid")                .build();//new callCall call = mOkHttpClient.newCall(request); //请求加入调度call.enqueue(new Callback()        {            @Override            public void onFailure(Request request, IOException e)            {            }            @Override            public void onResponse(final Response response) throws IOException            {                    //String htmlStr =  response.body().string();              runOnUiThread(new Runnable()      {          @Override          public void run()          {            mTv.setText(
htmlStr
); } }); } });