String[] urls={"www.baidu.com", "aaa.cn", "bb.com", "xbb.b", };
public void getUrl(final String url) { Thread thread= new Thread(){ @Override public void run() { OkHttpClient okHttpClient=new OkHttpClient(); Request request=new Request.Builder() .url("http:api.kindling.top/wechat/check?url=http://"+url) .build(); Response response=null; try { response = okHttpClient.newCall(request).execute(); if (response!=null) { if (response.isSuccessful()) { ResponseBody body = response.body(); String string = body.string(); JSONObject jsonObject=new JSONObject(string); Log.i("hongrenzhuang", "状态\t"+jsonObject.get("status")+""); if (jsonObject.get("status").equals("ok")) { userList.add(url); } else { nouserList.add(url); } } } } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } }; thread.start(); try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } }
demo github地址