Open sumankhan-android-lover opened 5 years ago
Have you initialized the library?
yes
implementation
'com.amitshekhar.android:jackson-android-networking:1.0.2'
Have you initialize like this AndroidNetworking.initialize(getApplicationContext());
Yes.that is exactly how I have initialised the library. I am having no difficulty in using this library. I am using this library throughout my project..
My only difficulty is in getting the cache to work whenever I try to apply your cache code as shown above, then the error comes.
On Sat, Jan 19, 2019, 2:49 PM AMIT SHEKHAR <notifications@github.com wrote:
Have you initialize like this AndroidNetworking.initialize(getApplicationContext());
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/amitshekhariitbhu/Fast-Android-Networking/issues/391#issuecomment-455763500, or mute the thread https://github.com/notifications/unsubscribe-auth/Ahi01nN18poEGAm0l9E9z_lbAmoYkE3sks5vEuMmgaJpZM4Z7VcU .
any update sir?
@Sumankhan420 Hello, i know its a late answer, but i came across the same issue and found that Cache will only work for GET requests with most of the Android Networking Libraries!
I am using the following code in Android :
AndroidNetworking.post(url) .addQueryParameter("id","123") .setPriority(Priority.LOW) .getResponseOnlyIfCached() .build() .getAsJSONObject(new JSONObjectRequestListener() { @Override public void onResponse(JSONObject response) { Log.e(TAG, "onResponse: "+response); } @Override public void onError(ANError anError) { Log.e(TAG, "onError: "+anError.getErrorDetail() ); Log.e(TAG, "onError: "+anError.getErrorCode() ); } });
My URL Links to a PHP Webservice API which is working perfectly fine on browsers and IOS Platforms. There I have provided the following cache-controls :
**header('Cache-Control: max-age=300, private'); header('Expires: Mon, 26 Jul 2019 05:00:00 GMT'); header('Content-type: application/json');
print_r($json);**
In Android I am getting the error :
onError: responseFromServerError onError: 504
If I remove the line "getResponseOnlyIfCached()" then the API works perfectly fine, but using Cache is not working.
Thanks