Skip to content

Instantly share code, notes, and snippets.

@a7madev
Last active December 29, 2015 18:39
Show Gist options
  • Save a7madev/7711836 to your computer and use it in GitHub Desktop.
Save a7madev/7711836 to your computer and use it in GitHub Desktop.
Get JSON Array from a webpage using Android Asynchronous Http Client http://loopj.com/android-async-http/
try {
RequestParams rParams = new RequestParams(); //if you have parameters to POST
rParams.put("example", "example"); //if you have parameters to POST
AsyncHttpClient client = new AsyncHttpClient();
client.get(pageURL, rParams, new JsonHttpResponseHandler() {
@Override
public void onSuccess(JSONArray jsonArray) {
super.onSuccess(jsonArray);
//process JSON Array
}
@Override
public void onFailure(Throwable throwable, JSONArray jsonArray) {
super.onFailure(throwable, jsonArray);
Log.d(TAG, "onFailure", throwable);
}
});
} catch (Exception e) {
Log.d(TAG, "Exception", e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment