Hey i'm using AsynHttpClient.
I would like to implement my get and set functions in one Activity where they can get called by others.
But how can i call my custom callback from the reponse callback?
I dont get it how it works in an inner class
public void requestApiUrl(Callback callback ){
JSONObject jsonObj = new JSONObject();
try {
jsonObj.put("AppKey",getResources().getString(R.string.AppKey));
AsyncHttpClient client = new AsyncHttpClient();
StringEntity entity = null;
try {
entity = new StringEntity(jsonObj.toString());
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
client.get(this, "***************URL***********", entity, "application/json", new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, cz.msebera.android.httpclient.Header[] headers, JSONObject utils) {
super.onSuccess(statusCode, headers, utils);
Log.d("HTTP", "response: " + utils.toString());
callback.reponse();
}
public void onFailure(int statusCode, cz.msebera.android.httpclient.Header[] headers, String responseString, Throwable throwable) {
super.onFailure(statusCode, headers, responseString, throwable);
Log.d("Failed: ", "" + statusCode);
Log.d("Error : ", "" + throwable);
callback.reponse();
}
});
}catch (JSONException e) {
e.printStackTrace();
}
}