0

I am making a GET request to: http://www.opensecrets.org/api/?method=getLegislators&apikey=xxx&output=json&id=ny using android asynchttp 1.4.3. I set multiple breakpoints, but no exception is thrown and none of the following callbacks are being invoked:

 APIclient.getLegislators(this, enteredState, new JsonHttpResponseHandler() {
        @Override
        public void onSuccess(JSONArray arr) {
            String s= "hello";
        }

        @Override
        public void onSuccess(JSONObject contactsJson) {
            ArrayList<Contact> contacts = Contact.fromJSON(contactsJson);
        }

        /*@Override
        public void onFailure(int statusCode, org.apache.http.Header[] headers, byte[] responseBytes, java.lang.Throwable throwable) {
            //super.onFailure(statusCode, headers, responseBytes, throwable);
        }*/

        @Override
        public void onFailure(Throwable arg0, JSONArray arg1) {
            super.onFailure(arg0, arg1);
            Toast.makeText(getApplicationContext(),
                    "Failed with JSONArray 2nd arg!", Toast.LENGTH_LONG).show();
        }

        // If it fails it fails here where arg1 is the error message(dev inactive)
        @Override
        public void onFailure(Throwable arg0, String arg1) {
            super.onFailure(arg0, arg1);
            Toast.makeText(getApplicationContext(),
                    "getTrailerUrl failed with String 2nd arg!",
                    Toast.LENGTH_LONG).show();
        }

        @Override
        public void onFailure(Throwable arg0, JSONObject arg1) {
            super.onFailure(arg0, arg1);
            Toast.makeText(getApplicationContext(),
                    "Failed with JSONObject 2nd arg!", Toast.LENGTH_LONG).show();
        }

    });

I tried to get an understanding of this by reviewing http://loopj.com/android-async-http/doc/com/loopj/android/http/JsonHttpResponseHandler.html

Based on that javadoc, I entered the callback you see commented out. I commented it out because the compiler did not recognize any such parent onFailure signature. Yet the onFailure's I have that don't produce compiler errors are not shown in the official documentation.

The solution in this SO post apparently was merged with the jar I have since that post was back in 2012: Loopj Android Async Http - onFailure not fired

What callback override am I missing? I'd like to see why my GET request isn't succeeding. Thanks

Community
  • 1
  • 1
HukeLau_DABA
  • 2,384
  • 6
  • 33
  • 51

1 Answers1

0

I forgot to allow my app to access the internet in the manifest. As for the documentation not matching my code's callbacks, the versions may not match because the signatures in the source of my android async 1.4.3 jar are consistent with my overrides.

HukeLau_DABA
  • 2,384
  • 6
  • 33
  • 51