Created
April 2, 2013 18:02
-
-
Save maxwellE/5294599 to your computer and use it in GitHub Desktop.
Code for loading red lights needs to be in an async task bc we are using json http request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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