在android中将数据发布到服务器

时间:2010-11-01 07:51:57

标签: android post cookies

我想通过android中的POST方法将一些数据发送到服务器。我使用以下代码

DefaultHttpClient hc=new DefaultHttpClient();  
ResponseHandler <String> res=new BasicResponseHandler();  
HttpPost postMethod=new HttpPost(url); 
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); 
nameValuePairs.add(new BasicNameValuePair("name", "value"));     
nameValuePairs.add(new BasicNameValuePair("password", "value"));    
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));    
String response=hc.execute(postMethod,res); 

但我在响应xml中收到错误响应。错误消息是客户端计算机中禁用cookie。我如何在Android中启用cookie?

1 个答案:

答案 0 :(得分:1)

您需要根据您的请求处理Cookie。请参阅thisthis相关问题。