0

I'm developing an app for Android. I made a class to parse an xml, when I load a local xml file it works, now I want to load an xml file from a web site. So I thought to use AsyncHttpClient to get the xml file and pass it to my parser. I made it so:

AsyncHttpClient client = new AsyncHttpClient();
client.get(url, new AsyncHttpResponseHandler() {
      @Override
      public void onSuccess(String response) {
             super.onSuccess(response);
             XmlParse xmlParse = new XmlParse(response);
             xmlParse.parseXml();
      }
});

But when I try to load the xml file I've trouble because it doesn't call the onSuccess method. Can anyone help me to solve this issue? Thank you

morten.c
  • 3,414
  • 5
  • 40
  • 45

1 Answers1

0

Use

@Override
     public void onFailure(Throwable e, String response) {
         // Response failed :(
     }

to see errors

mromer
  • 1,867
  • 1
  • 13
  • 18
  • I tried it now and I've the same issue: I setted a break point in method onSuccess and in method onFailure, but I still have the same problem, what should I do? It doesn't invoke the method onSuccess and the method onFailure –  Jul 16 '13 at 09:21
  • It's the first thing i checked... I set it so: So the internet permission is setted in manifest... Why I can connect to the internet? The device is connected to the internet by wi-fi shared from my Mac and when I try to load the site from Safari it works great... –  Jul 16 '13 at 09:24
  • Ok, first of all, override `@Override public void onStart() { // Initiated the request }` – mromer Jul 16 '13 at 09:25
  • I tried with onStart but it doesn't invoke the method... I put a Log.d in method onStart and in method onFailure to see if they will be invoke by the app, but I didn't see the log sentence i wrote... –  Jul 16 '13 at 09:27
  • This line is executed? `AsyncHttpClient client = new AsyncHttpClient();` – mromer Jul 16 '13 at 09:32
  • Sure, I tried it with debugger. Here you can see my graphic interface: http://postimg.org/image/metjbao5h/ (very stupid interface but I'm using it to understand how it works and to put my xmlparse class in my app) Here you can see my code: http://pastebin.com/3WvFneTc –  Jul 16 '13 at 09:34
  • Now it's working!!! I'm having trouble with xml parser but I will fix it. Thank you for the suggestion! –  Jul 16 '13 at 09:41