Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have parsed the data but never set to textview again.</p> <p>You can do that in onPostExecute this method will be called on UI Thread so its safe. (Never try to set any view's property in doInBackground that will lead you to an exception)</p> <pre><code>public void sendPostRequest() { class runCode extends AsyncTask&lt;String, String, String&gt; { // seperate task @Override protected String doInBackground(String... params) { ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); nameValuePairs.add(new BasicNameValuePair("idnum", "1")); try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://192.168.1.182/FYP/xshowall.php"); // PHP script to show all where id &gt; POST httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); } catch (Exception e) { Log.e("log_tag", "error in http conn " + e.toString()); } try { BufferedReader reader = new BufferedReader(new InputStreamReader(is), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result = sb.toString(); } catch (Exception e) { Log.e("log_tag", "error converting " + e.toString()); } try { JSONArray jArray = new JSONArray(result); for (int i = 0; i &lt; jArray.length(); i++) { JSONObject json_data = jArray.getJSONObject(i); json = "id: " + json_data.getInt("ID") + ", title: " + json_data.getString("TITLE") + ", content: " + json_data.getString("CONTENT"); ); } } catch (JSONException e) { Log.e("log_tag", "Error parsing data " + e.toString()); } return null; } @Override protected void onPostExecute(String result) { tv.setText(json); } } runCode sendPostReqAsyncTask = new runCode(); sendPostReqAsyncTask.execute(); } </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. VO
      singulars
      1. This table or related slice is empty.
    2. 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