Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>for Json</p> <pre><code> public class HttpRequests { private InputStream is = null; public HttpRequests() { } public String[] makeHttpRequest(String url, String method,List&lt;NameValuePair&gt; params) { String[] result = new String[2]; try { if(method == "POST"){ DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); result[0]="true"; }else if(method == "GET"){ DefaultHttpClient httpClient = new DefaultHttpClient(); String paramString = URLEncodedUtils.format(params, "utf-8"); url += "?" + paramString; HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); result[0]="true"; } }catch (UnsupportedEncodingException e) { result[0]=e.toString(); }catch (ClientProtocolException e) { result[0]=e.toString(); }catch (IOException e) { result[0]=e.toString(); } if(result[0]=="true"){ try { BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result[1]= sb.toString(); return result; }catch (Exception e) { result[0]= e.toString(); return result; } }else return result; } </code></pre> <p>where List is array which contain the item you want to send like this</p> <pre><code> List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("Name",name1)); params.add(new BasicNameValuePair("Email",email1)); HttpRequests myHttpRequests=new HttpRequests(); String[] responce= myHttpRequests.makeHttpRequest(SignUpURL, "POST", params); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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