Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Its not working. I am using the following class:</p> <pre><code>public class ConnectionManager { private ArrayList &lt;NameValuePair&gt; params; private ArrayList &lt;NameValuePair&gt; headers; private String url; public ConnectionManager(String url) { this.url = url; params = new ArrayList&lt;NameValuePair&gt;(); headers = new ArrayList&lt;NameValuePair&gt;(); } public void addParam(String name, String value) { params.add(new BasicNameValuePair(name, value)); } public void addHeader(String name, String value) { headers.add(new BasicNameValuePair(name, value)); } public String sendRequest() throws Exception { String serverResponse = ""; HttpPost httpPostRequest = new HttpPost(url); httpPostRequest.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE); //add headers for(int i = 0; i &lt; headers.size(); i++) { StringEntity entity = new StringEntity(headers.get(i).getValue(),"UTF-8"); httpPostRequest.setEntity(entity); } if(!params.isEmpty()){ HttpEntity httpEntity = new UrlEncodedFormEntity(params,HTTP.UTF_8); httpPostRequest.setEntity(httpEntity); } serverResponse = executeRequest(httpPostRequest); return serverResponse; } private String executeRequest(HttpUriRequest request) throws Exception { HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, 3000); HttpConnectionParams.setSoTimeout(params, 10000); DefaultHttpClient client = new DefaultHttpClient(params); HttpResponse httpResponse; String serverResponse = ""; httpResponse = client.execute(request); HttpEntity entity = httpResponse.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); serverResponse = convertStreamToString(instream); instream.close(); } Log.d("server response", serverResponse); return serverResponse; } private String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } return sb.toString(); } </code></pre>
 

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