I was looking forward to HTTP POST data from my android app with the current SDK, and actually it is pretty simple :
Using java Syntax Highlighting
- public void MyFunction{
- HttpClient httpclient = new DefaultHttpClient();
- //Your URL
- HttpPost httppost = new HttpPost("http://www.myurl.com/script.php");
- try {
- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
- //Your DATA
- nameValuePairs.add(new BasicNameValuePair("id", "12345"));
- nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- HttpResponse response;
- response=httpclient.execute(httppost);
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
And here it is!




