发送POST请求,被拒绝? 本帖最后由 ddddfpxx1 于 2014-03-26 18:04:51 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我之前有碰到过网络不好时,有些机型是会报connection xxx refused。你是一直被refuse吗?你试试其他的post好不好,或者看看是不是参数的原因。 下面是代码,看不出什么毛病啊!private OnClickListener listener=new OnClickListener(){@Overridepublic void onClick(View v){ String action="http://192.168.0.11/android/save.php"; HttpPost httpRequest=null; List <NameValuePair> params=null; HttpResponse httpResponse; if(sendBtn==v){ try { httpRequest=new HttpPost(action); params=new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("name",name.getText().toString())); params.add(new BasicNameValuePair("pass",pass.getText().toString())); httpRequest.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8)); httpResponse=new DefaultHttpClient().execute(httpRequest); if(httpResponse.getStatusLine().getStatusCode()==200){ String strResult=EntityUtils.toString(httpResponse.getEntity()); showDialog("info",strResult); }else{ showDialog("Error",httpResponse.getStatusLine().toString()); }}catch (Exception e){ showDialog("Exception",e.getMessage().toString()); } }}}; 为什么我用tabhost,图标显示不出来。 新手提问-我建了一个项目里有2个Activity,打包安装后装出2个图标 摇一摇功能 X、Y、Z三轴数据怎么校验 精度判断比较合适 谁有棋牌类游戏开发经验? 谷歌与友盟的sdk android手机开发高手帮帮忙?? asynchttpclient 在runnable 里面执行不成功 ffmpeg里的avformat_open_input调用失败 跪求:新浪微博Android开发视频教程真正的完整版 基于安卓的寝室电费自助充值app android 通过数据线和pc通讯 android 2.3.5 JSONObject 解析出错,4.0 上OK
你是一直被refuse吗?你试试其他的post好不好,或者看看是不是参数的原因。
@Override
public void onClick(View v){
String action="http://192.168.0.11/android/save.php";
HttpPost httpRequest=null;
List <NameValuePair> params=null;
HttpResponse httpResponse;
if(sendBtn==v){
try {
httpRequest=new HttpPost(action);
params=new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name",name.getText().toString()));
params.add(new BasicNameValuePair("pass",pass.getText().toString()));
httpRequest.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
httpResponse=new DefaultHttpClient().execute(httpRequest); if(httpResponse.getStatusLine().getStatusCode()==200){
String strResult=EntityUtils.toString(httpResponse.getEntity());
showDialog("info",strResult);
}else{
showDialog("Error",httpResponse.getStatusLine().toString());
}
}
catch (Exception e){
showDialog("Exception",e.getMessage().toString());
}
}
}
};