本文介绍了这样做的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://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));

这篇关于这样做的HTTP发布了Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 16:53