itgoyo / AndroidSummary

12 stars 4 forks source link

xUtils POST json数据请求 #58

Open itgoyo opened 6 years ago

itgoyo commented 6 years ago
                HttpUtils httpUtils = new HttpUtils();

                RequestParams params = new RequestParams();

                jsonObject.addProperty("loginId", "12345678901");

                try {
                    params.setBodyEntity(new StringEntity(jsonObject.toString(),"UTF-8"));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                params.setContentType("application/json");

                httpUtils.send(HttpRequest.HttpMethod.POST, "http://10.204.42.142:8080/user/userLogin", params, new RequestCallBack<String>() {
                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {
                        Log.i("itgoyo","-1->"+responseInfo.result);
                    }

                    @Override
                    public void onFailure(HttpException e, String s) {

                        Log.i("itgoyo","-2->"+s);
                    }
                });