使用界面。这样,您可以创建自己的回调,其回调方法可以从onSuccess或onFailure调用。
public interface onJSONResponseCallback { public void onJSONResponse(boolean success, JSonObject response);}public JSonObject getJSonObj(onJSONResponseCallback callback) { ... @Override public void onSuccess(int i, Header[] headers, String response) { try {jObj = new JSonObject(response);callback.onJSONResponse(true, jObj); } catch (JSonException e) {Log.e("Exception", "JSonException " + e.toString()); } } @Override public void onFailure(int statusCode, Header[] headers, String response, Throwable e) { try {jObj = new JSonObject(response);callback.onJSONResponse(false, jObj); } catch (JSonException e) {Log.e("Exception", "JSonException " + e.toString()); } }}并称之为:
jsonParse.getJSonObj(new onJSONResponseCallback(){ @Override public void onJSONResponse(boolean success, JSonObject response){ //do something with the JSON }});


