GET没有输入关于Susces和onFailure的方法

时间:2018-05-28 13:33:37

标签: android asynchttpclient

我试图使用AsyncHttpClient,但是没有进入这两种方法,在Postman中它进展顺利,任何想法可能是什么?

AsyncHttpClient client = new AsyncHttpClient();
    String URL = "http://link/link1/link2";
    client.get(URL, new AsyncHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            JSONArray dni;

            String strResponseBody = new String(responseBody);

            try {
                dni = new JSONArray(strResponseBody);
                for(int i=0; i < dni.length(); i ++){
                    dniTemporal = dni.getString(i);
                    Log.d("DNI : ",""+ dniTemporal );

                }

            } catch (JSONException e) {
                Toast.makeText(JourneyDetails.this, "Error", Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
            Log.d("ERROR STATUS:"," "+ statusCode);
        }

    });

0 个答案:

没有答案