I have a network class making use of the following lib: Lib Docs with 4 function to make a get, post delete and put request to the server. here is the simplified version:
public static void get(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
httpClient.get(context, getAbsoluteUrl(url), params, responseHandler);
}
Now instead of having to pass the context through via a paramter, Is there no possible way to some how get the context of the calling activity inside the fucntion?
some thing along the lines of:
public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
Context context = getCallignActivtyCntext() // <====== some thing like this
httpClient.get(context, getAbsoluteUrl(url), params, responseHandler);
}
the reason I need the specific context is because I have to cancel all network requests when an activity is destroyed, and it groups or identifies all requests by the context.