httpUtils网络请求

String path = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        HttpUtils httpUtils = new HttpUtils();
        // 参数一:请求方式
        // 参数二:url
        // 参数三:RequestParams params, 请求参数
        // 参数四:RequestCallBack<T> callBack 回调通知接口

        // RequestParams params=new RequestParams();
        //
        // params.addQueryStringParameter("key",
        // "49d49fb9ef38fdfdb0a649f258c1f992");
        // params.addQueryStringParameter("pno", pno+"");

        httpUtils.send(HttpMethod.GET, path, new RequestCallBack<String>() {

            @Override
            public void onFailure(HttpException arg0, String arg1) {
                Log.i("file", "请求失败");
            }

            @Override
            public void onSuccess(ResponseInfo<String> weResponseInfo) {

                String data = weResponseInfo.result;
                System.out.println(data);
                Log.i("file", data);

                Gson gson = new Gson();

//                NewsData[] newsDatas = gson.fromJson(data, NewsData[].class);
//
//                List<NewsData> list=new ArrayList<NewsData>(); 
//                for (NewsData newsData2 : newsDatas) {
//                    list.add(newsData2);
//                }
                

            }

        });

 

posted on 2016-05-30 21:24  glj521  阅读(658)  评论(0编辑  收藏  举报