/** * 使用xUtils实现GET请求 * */ private void getExpressionForGet(){ //xUtils 基于HttpClient的 HttpUtils httpUtils = new HttpUtils(5000); httpUtils.send(HttpRequest.HttpMethod.GET, "http://v.juhe.cn/WNXG/city?key=3c7900adf363b38a0201ffebda71e95a", new RequestCallBack<String>() { @Override public void onStart() { super.onStart(); //开始发送请求,显示进度条 } @Override public void onSuccess(ResponseInfo<String> responseInfo) { //成功 String result = responseInfo.result; System.out.println("得到结果 : "+result); } @Override public void onFailure(HttpException e, String s) { //失败 } }); }
时间: 2024-10-09 23:28:39