Skip to content

Instantly share code, notes, and snippets.

@maxwellE
Created April 2, 2013 18:02
Code for loading red lights needs to be in an async task bc we are using json http request
public void executeAsyncGet(View view) {
AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
params.put("latitude", "40.192512");
params.put("longitude", "-83.526306");
params.put("distance_in_miles", "10000");
client.get("http://redlights.herokuapp.com/in_proximity_of",params ,new JsonHttpResponseHandler() {
@Override
public void onSuccess(JSONArray red_lights) {
for (int i = 0; i < red_lights.length(); i++) {
try {
JSONObject redLight = red_lights.getJSONObject(i);
Log.d("FOUND RED LIGHT",redLight.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
Log.d("JSON ERROR", e.getMessage());
}
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment