Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use <a href="http://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java" rel="nofollow"><code>ResponseHandler</code></a>. One line of code. See <a href="http://github.com/commonsguy/cw-android/tree/master/Service/WeatherPlus/" rel="nofollow">here</a> and <a href="http://github.com/commonsguy/cw-andtutorials/tree/master/15-HttpClient/Patchy/" rel="nofollow">here</a> for sample Android projects using it.</p> <pre><code>public void postData() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://www.yoursite.com/user"); try { // Add your data List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2); nameValuePairs.add(new BasicNameValuePair("id", "12345")); nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request ResponseHandler&lt;String&gt; responseHandler=new BasicResponseHandler(); String responseBody = httpclient.execute(httppost, responseHandler); JSONObject response=new JSONObject(responseBody); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } } </code></pre> <p>add combination of this post and complete HttpClient at - <a href="http://www.androidsnippets.org/snippets/36/" rel="nofollow">http://www.androidsnippets.org/snippets/36/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload