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)