Skip to content

Commit

Permalink
Process JSON response, get count and check pressure readings
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobSheehy committed Apr 21, 2013
1 parent c5334a2 commit 6223539
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/ca/cumulonimbus/pressurenetsdk/test/APITest.java
Expand Up @@ -12,6 +12,8 @@
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;

import android.app.Activity;
import android.content.Intent;
Expand Down Expand Up @@ -80,9 +82,23 @@ protected String doInBackground(String... arg0) {
return responseText;
}
protected void onPostExecute(String result) {
System.out.println("datadownload post execute " + result);
//System.out.println("datadownload post execute " + result);
processJSONResult(result);
}
}

void processJSONResult(String resultJSON) {
try {
JSONArray jsonArray = new JSONArray(resultJSON);
System.out.println("Result Count: " + jsonArray.length());
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
System.out.println(jsonObject.getDouble("reading"));
}
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down

0 comments on commit 6223539

Please sign in to comment.