这样做的HTTP发布了Android这样做、发布了、HTTP、Android

由网友(远航)分享简介:我要通过POST方法在我apllication一些值传递到一个URL。请帮助I need to pass some values to a URL by Post Method in my apllication. Please Help推荐答案下面是一些code,这将使一个HTTP POST请求。从 http:...

我要通过POST方法在我apllication一些值传递到一个URL。请帮助

I need to pass some values to a URL by Post Method in my apllication. Please Help

推荐答案

下面是一些code,这将使一个HTTP POST请求。从 http://androidadvice.blogspot.com/2010/10/httppost-request拍摄html的,其中有一些额外的解释也是如此。

Here's some code that will make an HTTP POST request. Taken from http://androidadvice.blogspot.com/2010/10/httppost-request.html, which has some additional explanation as well.

HttpClient httpclient =  new DefaultHttpClient(httpParameters);
HttpPost httppost = new HttpPost(Constants.MAIN_URL);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("u", eUsername));
nameValuePairs.add(new BasicNameValuePair("p", ePassword));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
阅读全文

相关推荐

最新文章