Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>private class GetTask extends AsyncTask&lt;String, Void, JSONItems&gt; { @Override protected JSONItems doInBackground(String... uri) { JSONItems result = new JSONItems(); HttpClient httpClient = new DefaultHttpClient(); HttpResponse response; HttpGet request = new HttpGet(uri[0]); String responseString = null; try { response = httpClient.execute(request); StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() == HttpStatus.SC_OK) { ByteArrayOutputStream out = new ByteArrayOutputStream(); response.getEntity().writeTo(out); out.close(); responseString = out.toString(); JSONObject jSonObject = new JSONObject(responseString); JSONArray jSonArray = jSonObject .getJSONArray("items"); if (jSonArray.length() &gt; 0) { for (int j = 0; j &lt; jSonArray.length(); j++) { result = convertJSONItems(jSonArray .getJSONObject(j)); } return result; } } else { // Closes the connection. response.getEntity().getContent().close(); throw new IOException(statusLine.getReasonPhrase()); } } catch (ClientProtocolException e) { // TODO Handle problems.. } catch (IOException e) { // TODO Handle problems.. } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } @Override protected void onPostExecute(JSONItems result) { if (result != null) { //TODO : Do what you want to do .. } } @Override protected void onCancelled(JSONItems result) { } private JSONItems convertJSONItems(JSONObject obj) throws JSONException { JSONItems item = new JSONItems(); item.datetime = obj.getString("datetime"); item.foods = obj.getString("foods"); return item; } } </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.
 

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