5

I'm trying to connect means AsyncHttpClient to a php script on my website. The script do the html parsing of another page, and convert the result to json. it work well. But, when I try to take the json form java for using it on android, the method that have the only work of open a stream and return 'response', doesn't run onSuccess and onFailure both. can anyone help me? Here the code:

private String getStream() {

    AsyncHttpClient client = new AsyncHttpClient();

    client.get("http://jem88.net/eventsAroundYouParser.php", new AsyncHttpResponseHandler() {
         @Override
         public void onSuccess(String response) {

             System.out.println("response is here..."+response);
             Log.d("eventstaker", "into response!!");

         }

         @Override
         public void onFailure(Throwable e, String response) {
             Log.d("eventstaker", "onFailure method is run... :(");
         }

     });
    return "";
}`

I've set the internet and network_access permission in the manifest. Thank you in advance

morten.c
  • 3,414
  • 5
  • 40
  • 45
Marino
  • 800
  • 1
  • 12
  • 26

1 Answers1

3

You can override more onFailure methods

mromer
  • 1,867
  • 1
  • 13
  • 18
  • Thanks for your answer mromer, you say For check more possibile exception? If i Override others onFailure the compiler tell me to rename methods! All others exceptions are checked before this method.. I don't think is an exception! – Marino May 17 '13 at 10:08
  • 1
    You can override 'public void onFailure(Throwable arg0)' – mromer May 17 '13 at 10:38
  • ok, but what should i check into this onFailure? Sorry, i'm newer to java – Marino May 17 '13 at 10:45
  • 1
    you can override 'onFailure(Throwable e, String response)' AND 'onFailure(Throwable arg0)'. Some bugs will execute the first method, and another bugs will execute the second method. Now you can see the detailled bug doing Debug step by step or with logs. – mromer May 17 '13 at 10:56