Fast-Android-Networking icon indicating copy to clipboard operation
Fast-Android-Networking copied to clipboard

Question : How to handle this response

Open AndroidDeveloperMCT opened this issue 5 years ago • 0 comments

?({ "Years": {"min_year":"1941", "max_year":"2019"} });

New to this library. @amitshekhariitbhu Can you please help

I've tried this yet void getYears() {

    Gson gson = new GsonBuilder()
            .setLenient()
            .create();

    AndroidNetworking.setParserFactory(new GsonParserFactory(gson));

    AndroidNetworking.get("https://www.carqueryapi.com/api/0.3/?callback=?&cmd=getYears")
            .setTag("getYears")
            .setPriority(Priority.IMMEDIATE)
            .build()
            .getAsOkHttpResponse(new OkHttpResponseListener() {
                @Override
                public void onResponse(Response response) {
                    // do anything with response
                    if (response.isSuccessful()) {
                        Constant.showSuccessToast(response.message(), getApplicationContext());
                    }
                }
                @Override
                public void onError(ANError anError) {
                    // handle error
                    Constant.showErrorToast(anError.getMessage(), getApplicationContext());
                }
            });
}

AndroidDeveloperMCT avatar Jan 10 '20 13:01 AndroidDeveloperMCT