美文网首页
xutils post: josn的小问题

xutils post: josn的小问题

作者: 那落_ | 来源:发表于2017-07-18 11:50 被阅读0次
     private void submitJson(){
        HttpUtils httputils=new HttpUtils();
        RequestParams params=new RequestParams("UTF-8");
        try{
             //这里注释的有点BUG服务器无法获取数据,只能用addBodyParameter
            //params.setBodyEntity(new StringEntity(mapToJson(Mymap), "UTF-8"));
            //params.setContentType("application/json");
    
            String content=et_content.getText().toString();
            String mail=et_mail.getText().toString();
         params.addBodyParameter("mail", mail);
         params.addBodyParameter("content", content);
         params.addBodyParameter("DeviceId", getDeviceId());
         params.addBodyParameter("OptionText", radioButtonText);
            
        }catch(Exception e){
            e.printStackTrace();
        }
        
        httputils.send(HttpMethod.POST, url, params,new RequestCallBack<String>() {
    
            @Override
            public void onFailure(HttpException arg0, String arg1) {
                // TODO Auto-generated method stub
                Log.i("Mylog","失败");
                Toast.makeText(act, "反馈发送失败",Toast.LENGTH_SHORT).show();
                
            }
    
            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                // TODO Auto-generated method stub
                if(arg0.statusCode==200){
                    
                    Log.i("Mylog","成功");
                    Toast.makeText(act, "反馈发送成功",Toast.LENGTH_SHORT).show();
                    
                }
            }
        });
        
        
    }

    相关文章

      网友评论

          本文标题:xutils post: josn的小问题

          本文链接:https://www.haomeiwen.com/subject/bbnckxtx.html