Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can get data from servlet to andriod application through <code>json format</code>. Please go through this<br> <a href="http://wiebe-elsinga.com/blog/?p=405" rel="nofollow">http://wiebe-elsinga.com/blog/?p=405</a> link to get an idea of how to call Servlet from andriod application and get the response back in json format.</p> <p><strong>call to Servlet from Andriod</strong></p> <pre><code> private InputStream callService(String text) { InputStream in = null; SERVLET_URL = http://wizkid.com/web/updateServlet"; try { URL url = new URL(SERVLET_URL); URLConnection conn = url.openConnection(); HttpURLConnection httpConn = (HttpURLConnection) conn; httpConn.setRequestMethod("POST"); httpConn.setDoInput(true); httpConn.setDoOutput(true); httpConn.connect(); DataOutputStream dataStream = new DataOutputStream(conn .getOutputStream()); dataStream.writeBytes(text); dataStream.flush(); dataStream.close(); int responseCode = httpConn.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { in = httpConn.getInputStream(); } } catch (Exception ex) { display("Error: Not not connect"); } return in; } </code></pre> <p>// Get Data from Server to andriod</p> <pre><code> private String getResultFromServlet(String text) { String result = ""; InputStream in = callService(text); if (in != null) { JSONObject jsonResponse; try { jsonResponse = new JSONObject(convertStreamToString(in)); result = jsonResponse.getString("output"); } catch (JSONException e) { result = "Error: JSON Object couldn't be made"; } } else { result = "Error: Service not returning result"; } return result; } </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. This table or related slice is empty.
    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