I am working on an android application to which I have integrated 20 APIs using AsyncHttpClient, for every API call I have to implement these two below methods to get the Response whether it is success hit or failure.
client.post(context,url,null,AppConstant.APPLICATION_JSON_CONTENT,new AsyncHttpResponseHandler(){
@Override
public void onSuccess(int statusCode,cz.msebera.android.httpclient.Header[]headers,byte[]responseBody){
}
@Override
public void onFailure(int statusCode,cz.msebera.android.httpclient.Header[]headers,byte[]responseBody,Throwable error){
}
});
I want to remove replication of these two methods from every activity on every API call.
Is it possible to create a class or interface to which I will pass on the URL, request parameters and header etc. required for API call and there I will define these two methods and this class/interface will be accessed for every API call. in return, it will provide me the response of the API