Static Http Client not giving callbacks

163 Views Asked by At

I used Loopj Android library for Post requests it works fine when I don't use Static Http Client but when I use Static Http Client it does not give any callback here is my code for class of HttpClient

import com.loopj.android.http.*;

public class MyHttpClient {


          private static final String BASE_URL = "http://www.google.com";

          private static AsyncHttpClient client = new AsyncHttpClient();

          public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
              client.post(getAbsoluteUrl(url), params, responseHandler);
              System.out.println("post called");
          }

          public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
                client.get(getAbsoluteUrl(url), params, responseHandler);

            }

          private static String getAbsoluteUrl(String relativeUrl) {
              return BASE_URL + relativeUrl;
          }

}

Here is how I call it

MyHttpClient.post("", params, new AsyncHttpResponseHandler(){
                        @Override
                        public void onSuccess(String response) {

                            System.out.println(response);

                        }
                    });

and I have added Internet permission in manifest so there is no issue of permissions here kindly help

0

There are 0 best solutions below