1

I have connection to google for testing this library in this way:

String url = "http://www.google.it”;
AsyncHttpClient.getDefaultInstance().executeString(
                new AsyncHttpGet(url), new AsyncHttpClient.StringCallback() {

                    @Override
                    public void onCompleted(Exception e, AsyncHttpResponse source, String result) {

                        if (e != null) {
                            Log.d("myTag", “ERROR");
                            Log.d("myTag", e.toString());
                            //e.printStackTrace();
                            return;
                        }
                        Log.d("myTag", result);

                    }

                    @Override
                    public void onConnect(AsyncHttpResponse response) {
                        super.onConnect(response);
                        Log.d("myTag", “CONNECTED");

                    }
                }
        );

This above works but how Do I get network error(for example I haven’t internet connection or get disconnected) because , for example , I haven’t internet connection before launch app in this way I don’t go onCompleted method.

I use AndroidAsync library (https://github.com/koush/AndroidAsync)

arturo
  • 51
  • 1
  • 7
  • 1
    Doesn't the library provide method similar to onFailure(), why don't you try overriding the methods and seeing for that – Harshit Kumar Aug 13 '16 at 17:36
  • As @HarshitKumar suggest please implement `onFailure()` method, or you can [check internet](http://stackoverflow.com/a/4239019/2949612) connection before make AsyncHttpClient call. – pRaNaY Aug 13 '16 at 17:42
  • Do you know library that do that? – arturo Aug 13 '16 at 17:46

0 Answers0