开发者

Post data to server in android

I want to send some data to a server through POST method in android. I am using the following code

DefaultHttpClient hc=new DefaultHttpClient();  
ResponseHandler <String> res=new BasicResponseHandler开发者_JS百科();  
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); 

But I am getting the error response in my response xml. The error message is cookies are disabled in client machine. How do I need to enable cookies in android ?


You need to handle cookies with your request. See this and this related questions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜