loopj/android-async-http — Issue #20: Error on Web Page Example
Author: sirvaliance
Created: 2011-10-12 05:05:58+00:00
State: open

Example text should match the example in the source repository:

*Incorrect (JSONArray response should be timeline)*

public void onSuccess(JSONArray response) {
// Pull out the first event on the public timeline
JSONObject firstEvent = timeline.get(0);
String tweetText = firstEvent.getString("text");

// Do something with the response
System.out.println(tweetText);
}

*Correct*
public void onSuccess(JSONArray timeline) {
try {
JSONObject firstEvent = (JSONObject)timeline.get(0);
String tweetText = firstEvent.getString("text");

// Do something with the response
System.out.println(tweetText);
} catch(JSONException e) {
e.printStackTrace();
}
}