xutils post: josn的小问题

2017-07-18  本文已影响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();
                
            }
        }
    });
    
    
}
上一篇下一篇

猜你喜欢

热点阅读