4

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

mohammedsuhail
  • 701
  • 2
  • 11
  • 23

2 Answers2

6

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));
Fred Sauer
  • 1,012
  • 9
  • 20
Tom
  • 174
  • 1
  • 4
1

You need to use HttpClient. See a related question here.

Community
  • 1
  • 1
kgiannakakis
  • 103,016
  • 27
  • 158
  • 194