Android Volley StringRequest not working sometimes The 2019 Stack Overflow Developer Survey Results Are InExoPlayer not playing anymore, stuck on Player.STATE_BUFFERINGIs there a way to run Python on Android?How do save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Is there a unique Android device ID?What is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?Store Volley Request dataVolley Server error<!DOCTYPE HTML PUBLIC "-//IETF/, Volley Server Error, JSONArray not converting, When Retrofit,Postman Executing urlVolley unable to host header parameters to server

Why do UK politicians seemingly ignore opinion polls on Brexit?

Who coined the term "madman theory"?

Am I thawing this London Broil safely?

Time travel alters history but people keep saying nothing's changed

What do the Banks children have against barley water?

FPGA - DIY Programming

Interpreting the 2019 New York Reproductive Health Act?

When should I buy a clipper card after flying to OAK?

Apparent duplicates between Haynes service instructions and MOT

Is a "Democratic" Oligarchy-Style System Possible?

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

Aging parents with no investments

Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?

Did 3000BC Egyptians use meteoric iron weapons?

One word riddle: Vowel in the middle

Loose spokes after only a few rides

Falsification in Math vs Science

What did it mean to "align" a radio?

Can one be advised by a professor who is very far away?

Did Section 31 appear in Star Trek: The Next Generation?

Does a dangling wire really electrocute me if I'm standing in water?

How to notate time signature switching consistently every measure

Can you compress metal and what would be the consequences?

If a Druid sees an animal’s corpse, can they Wild Shape into that animal?



Android Volley StringRequest not working sometimes



The 2019 Stack Overflow Developer Survey Results Are InExoPlayer not playing anymore, stuck on Player.STATE_BUFFERINGIs there a way to run Python on Android?How do save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Is there a unique Android device ID?What is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?Store Volley Request dataVolley Server error<!DOCTYPE HTML PUBLIC "-//IETF/, Volley Server Error, JSONArray not converting, When Retrofit,Postman Executing urlVolley unable to host header parameters to server



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm using the code below to get some local video URL from an API.



public void getVideoAds(String serverURL)
String url = "http://"+serverURL+"/video/";

StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>()
@Override
public void onResponse(String response)
try
JSONObject jsonObj = new JSONObject(response);
JSONObject defaultObj = jsonObj.getJSONObject("default");
JSONArray videoObj = jsonObj.getJSONArray("videos");

defaultUrl = defaultObj.getString("url");

for (int i = 0; i < videoObj.length(); i++)
JSONObject video = videoObj.getJSONObject(i);

VideoAd v = new VideoAd();
v.setName(getVideoNameFromLink(video.getString("url")));
v.setUrl(video.getString("url"));
v.setVideoId(video.getInt("id"));
v.setVersion(video.getInt("version"));
v.setLocalPath("");

vidArrLst.add(v);


playLoopVideo();
catch (Exception e)
Log.d(TAG, "getVidAds res err: " + e.getMessage());



, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();
Log.d(TAG, "getVidAds err: " + error.getMessage());

);

queue.add(stringRequest);



And inside onCreate(), I initialize RequestQueue like this.



queue = Volley.newRequestQueue(this);


Sometimes, getVideoAds() works. Sometimes, it doesn't work. The weird thing as well is that I'm not getting any error even after using Exception on my catch(). If it doesn't work, I do a Clean Project -> Rebuild Project -> Make Project and it works again. But after a few builds, mostly just 1 more build, it stops working again.



If you want to know more about playLoopVideo, look at this SO question I made. It's about the video playing part of my app. It currently doesn't play the video if I try to play it inside the onResponse of getVideoAds that's why I made a different question for it because maybe if I fix my Volley the video would play again.



This is my build.gradle(app) if you need it.



apply plugin: 'com.android.application'

android
compileSdkVersion 28
defaultConfig
applicationId "biz.net.com.streamer"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'


compileOptions
sourceCompatibility 1.8
targetCompatibility 1.8



dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.exoplayer:exoplayer:2.9.1'
implementation 'com.android.volley:volley:1.1.1'



UPDATE:



This is really weird. My getVideoAds() method is called inside another method that calls a method the makes a StringRequest on a different API on the same server. To make it easier to understand below is the code for it.



private void getAdvertisements(final String serverURL)
getVideoAds(serverURL);
getMessageAds(serverURL);

new android.os.Handler().postDelayed(
new Runnable()
public void run()
Log.d(TAG, "Updating ads marquee");
getMessageAds(serverURL);

,
300000);



Currently, the API that getMessageAds() calls don't return anything. I tried to comment it and the handler below and it finally worked. Even the video playing worked. I then tried to uncomment getMessageAds() and add a few messages on the server, everything is working fine. But after I remove the messages, it stops working again.



What could be the reason for this to happen?










share|improve this question
























  • new Response.ErrorListener() @Override public void onErrorResponse(VolleyError error) Log.d("Error", error.toString()); ); try to debug here. If any error occurred then you will get the error here.

    – Al-Amin
    Mar 22 at 4:09











  • As I've said, I'm not getting any error anywhere. In my real code, I even have a Toast inside Response.ErrorListener but it show up. This is the Toast I have inside the Response.ErrorListener. Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();

    – rminaj
    Mar 22 at 4:13











  • Have you checked catch block?

    – Al-Amin
    Mar 22 at 4:24











  • Please see my update.

    – rminaj
    Mar 22 at 4:51











  • @Al-Amin sorry. What I mean is that the Toast doesn't show up. Some typo error on my part.

    – rminaj
    Mar 22 at 4:58

















0















I'm using the code below to get some local video URL from an API.



public void getVideoAds(String serverURL)
String url = "http://"+serverURL+"/video/";

StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>()
@Override
public void onResponse(String response)
try
JSONObject jsonObj = new JSONObject(response);
JSONObject defaultObj = jsonObj.getJSONObject("default");
JSONArray videoObj = jsonObj.getJSONArray("videos");

defaultUrl = defaultObj.getString("url");

for (int i = 0; i < videoObj.length(); i++)
JSONObject video = videoObj.getJSONObject(i);

VideoAd v = new VideoAd();
v.setName(getVideoNameFromLink(video.getString("url")));
v.setUrl(video.getString("url"));
v.setVideoId(video.getInt("id"));
v.setVersion(video.getInt("version"));
v.setLocalPath("");

vidArrLst.add(v);


playLoopVideo();
catch (Exception e)
Log.d(TAG, "getVidAds res err: " + e.getMessage());



, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();
Log.d(TAG, "getVidAds err: " + error.getMessage());

);

queue.add(stringRequest);



And inside onCreate(), I initialize RequestQueue like this.



queue = Volley.newRequestQueue(this);


Sometimes, getVideoAds() works. Sometimes, it doesn't work. The weird thing as well is that I'm not getting any error even after using Exception on my catch(). If it doesn't work, I do a Clean Project -> Rebuild Project -> Make Project and it works again. But after a few builds, mostly just 1 more build, it stops working again.



If you want to know more about playLoopVideo, look at this SO question I made. It's about the video playing part of my app. It currently doesn't play the video if I try to play it inside the onResponse of getVideoAds that's why I made a different question for it because maybe if I fix my Volley the video would play again.



This is my build.gradle(app) if you need it.



apply plugin: 'com.android.application'

android
compileSdkVersion 28
defaultConfig
applicationId "biz.net.com.streamer"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'


compileOptions
sourceCompatibility 1.8
targetCompatibility 1.8



dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.exoplayer:exoplayer:2.9.1'
implementation 'com.android.volley:volley:1.1.1'



UPDATE:



This is really weird. My getVideoAds() method is called inside another method that calls a method the makes a StringRequest on a different API on the same server. To make it easier to understand below is the code for it.



private void getAdvertisements(final String serverURL)
getVideoAds(serverURL);
getMessageAds(serverURL);

new android.os.Handler().postDelayed(
new Runnable()
public void run()
Log.d(TAG, "Updating ads marquee");
getMessageAds(serverURL);

,
300000);



Currently, the API that getMessageAds() calls don't return anything. I tried to comment it and the handler below and it finally worked. Even the video playing worked. I then tried to uncomment getMessageAds() and add a few messages on the server, everything is working fine. But after I remove the messages, it stops working again.



What could be the reason for this to happen?










share|improve this question
























  • new Response.ErrorListener() @Override public void onErrorResponse(VolleyError error) Log.d("Error", error.toString()); ); try to debug here. If any error occurred then you will get the error here.

    – Al-Amin
    Mar 22 at 4:09











  • As I've said, I'm not getting any error anywhere. In my real code, I even have a Toast inside Response.ErrorListener but it show up. This is the Toast I have inside the Response.ErrorListener. Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();

    – rminaj
    Mar 22 at 4:13











  • Have you checked catch block?

    – Al-Amin
    Mar 22 at 4:24











  • Please see my update.

    – rminaj
    Mar 22 at 4:51











  • @Al-Amin sorry. What I mean is that the Toast doesn't show up. Some typo error on my part.

    – rminaj
    Mar 22 at 4:58













0












0








0








I'm using the code below to get some local video URL from an API.



public void getVideoAds(String serverURL)
String url = "http://"+serverURL+"/video/";

StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>()
@Override
public void onResponse(String response)
try
JSONObject jsonObj = new JSONObject(response);
JSONObject defaultObj = jsonObj.getJSONObject("default");
JSONArray videoObj = jsonObj.getJSONArray("videos");

defaultUrl = defaultObj.getString("url");

for (int i = 0; i < videoObj.length(); i++)
JSONObject video = videoObj.getJSONObject(i);

VideoAd v = new VideoAd();
v.setName(getVideoNameFromLink(video.getString("url")));
v.setUrl(video.getString("url"));
v.setVideoId(video.getInt("id"));
v.setVersion(video.getInt("version"));
v.setLocalPath("");

vidArrLst.add(v);


playLoopVideo();
catch (Exception e)
Log.d(TAG, "getVidAds res err: " + e.getMessage());



, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();
Log.d(TAG, "getVidAds err: " + error.getMessage());

);

queue.add(stringRequest);



And inside onCreate(), I initialize RequestQueue like this.



queue = Volley.newRequestQueue(this);


Sometimes, getVideoAds() works. Sometimes, it doesn't work. The weird thing as well is that I'm not getting any error even after using Exception on my catch(). If it doesn't work, I do a Clean Project -> Rebuild Project -> Make Project and it works again. But after a few builds, mostly just 1 more build, it stops working again.



If you want to know more about playLoopVideo, look at this SO question I made. It's about the video playing part of my app. It currently doesn't play the video if I try to play it inside the onResponse of getVideoAds that's why I made a different question for it because maybe if I fix my Volley the video would play again.



This is my build.gradle(app) if you need it.



apply plugin: 'com.android.application'

android
compileSdkVersion 28
defaultConfig
applicationId "biz.net.com.streamer"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'


compileOptions
sourceCompatibility 1.8
targetCompatibility 1.8



dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.exoplayer:exoplayer:2.9.1'
implementation 'com.android.volley:volley:1.1.1'



UPDATE:



This is really weird. My getVideoAds() method is called inside another method that calls a method the makes a StringRequest on a different API on the same server. To make it easier to understand below is the code for it.



private void getAdvertisements(final String serverURL)
getVideoAds(serverURL);
getMessageAds(serverURL);

new android.os.Handler().postDelayed(
new Runnable()
public void run()
Log.d(TAG, "Updating ads marquee");
getMessageAds(serverURL);

,
300000);



Currently, the API that getMessageAds() calls don't return anything. I tried to comment it and the handler below and it finally worked. Even the video playing worked. I then tried to uncomment getMessageAds() and add a few messages on the server, everything is working fine. But after I remove the messages, it stops working again.



What could be the reason for this to happen?










share|improve this question
















I'm using the code below to get some local video URL from an API.



public void getVideoAds(String serverURL)
String url = "http://"+serverURL+"/video/";

StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>()
@Override
public void onResponse(String response)
try
JSONObject jsonObj = new JSONObject(response);
JSONObject defaultObj = jsonObj.getJSONObject("default");
JSONArray videoObj = jsonObj.getJSONArray("videos");

defaultUrl = defaultObj.getString("url");

for (int i = 0; i < videoObj.length(); i++)
JSONObject video = videoObj.getJSONObject(i);

VideoAd v = new VideoAd();
v.setName(getVideoNameFromLink(video.getString("url")));
v.setUrl(video.getString("url"));
v.setVideoId(video.getInt("id"));
v.setVersion(video.getInt("version"));
v.setLocalPath("");

vidArrLst.add(v);


playLoopVideo();
catch (Exception e)
Log.d(TAG, "getVidAds res err: " + e.getMessage());



, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();
Log.d(TAG, "getVidAds err: " + error.getMessage());

);

queue.add(stringRequest);



And inside onCreate(), I initialize RequestQueue like this.



queue = Volley.newRequestQueue(this);


Sometimes, getVideoAds() works. Sometimes, it doesn't work. The weird thing as well is that I'm not getting any error even after using Exception on my catch(). If it doesn't work, I do a Clean Project -> Rebuild Project -> Make Project and it works again. But after a few builds, mostly just 1 more build, it stops working again.



If you want to know more about playLoopVideo, look at this SO question I made. It's about the video playing part of my app. It currently doesn't play the video if I try to play it inside the onResponse of getVideoAds that's why I made a different question for it because maybe if I fix my Volley the video would play again.



This is my build.gradle(app) if you need it.



apply plugin: 'com.android.application'

android
compileSdkVersion 28
defaultConfig
applicationId "biz.net.com.streamer"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'


compileOptions
sourceCompatibility 1.8
targetCompatibility 1.8



dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.exoplayer:exoplayer:2.9.1'
implementation 'com.android.volley:volley:1.1.1'



UPDATE:



This is really weird. My getVideoAds() method is called inside another method that calls a method the makes a StringRequest on a different API on the same server. To make it easier to understand below is the code for it.



private void getAdvertisements(final String serverURL)
getVideoAds(serverURL);
getMessageAds(serverURL);

new android.os.Handler().postDelayed(
new Runnable()
public void run()
Log.d(TAG, "Updating ads marquee");
getMessageAds(serverURL);

,
300000);



Currently, the API that getMessageAds() calls don't return anything. I tried to comment it and the handler below and it finally worked. Even the video playing worked. I then tried to uncomment getMessageAds() and add a few messages on the server, everything is working fine. But after I remove the messages, it stops working again.



What could be the reason for this to happen?







android android-volley






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 7:45









Tanveer Munir

1,6881422




1,6881422










asked Mar 22 at 3:56









rminajrminaj

358




358












  • new Response.ErrorListener() @Override public void onErrorResponse(VolleyError error) Log.d("Error", error.toString()); ); try to debug here. If any error occurred then you will get the error here.

    – Al-Amin
    Mar 22 at 4:09











  • As I've said, I'm not getting any error anywhere. In my real code, I even have a Toast inside Response.ErrorListener but it show up. This is the Toast I have inside the Response.ErrorListener. Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();

    – rminaj
    Mar 22 at 4:13











  • Have you checked catch block?

    – Al-Amin
    Mar 22 at 4:24











  • Please see my update.

    – rminaj
    Mar 22 at 4:51











  • @Al-Amin sorry. What I mean is that the Toast doesn't show up. Some typo error on my part.

    – rminaj
    Mar 22 at 4:58

















  • new Response.ErrorListener() @Override public void onErrorResponse(VolleyError error) Log.d("Error", error.toString()); ); try to debug here. If any error occurred then you will get the error here.

    – Al-Amin
    Mar 22 at 4:09











  • As I've said, I'm not getting any error anywhere. In my real code, I even have a Toast inside Response.ErrorListener but it show up. This is the Toast I have inside the Response.ErrorListener. Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();

    – rminaj
    Mar 22 at 4:13











  • Have you checked catch block?

    – Al-Amin
    Mar 22 at 4:24











  • Please see my update.

    – rminaj
    Mar 22 at 4:51











  • @Al-Amin sorry. What I mean is that the Toast doesn't show up. Some typo error on my part.

    – rminaj
    Mar 22 at 4:58
















new Response.ErrorListener() @Override public void onErrorResponse(VolleyError error) Log.d("Error", error.toString()); ); try to debug here. If any error occurred then you will get the error here.

– Al-Amin
Mar 22 at 4:09





new Response.ErrorListener() @Override public void onErrorResponse(VolleyError error) Log.d("Error", error.toString()); ); try to debug here. If any error occurred then you will get the error here.

– Al-Amin
Mar 22 at 4:09













As I've said, I'm not getting any error anywhere. In my real code, I even have a Toast inside Response.ErrorListener but it show up. This is the Toast I have inside the Response.ErrorListener. Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();

– rminaj
Mar 22 at 4:13





As I've said, I'm not getting any error anywhere. In my real code, I even have a Toast inside Response.ErrorListener but it show up. This is the Toast I have inside the Response.ErrorListener. Toast.makeText(ctx, "VideoAds Err: "+error.getLocalizedMessage(), Toast.LENGTH_LONG).show();

– rminaj
Mar 22 at 4:13













Have you checked catch block?

– Al-Amin
Mar 22 at 4:24





Have you checked catch block?

– Al-Amin
Mar 22 at 4:24













Please see my update.

– rminaj
Mar 22 at 4:51





Please see my update.

– rminaj
Mar 22 at 4:51













@Al-Amin sorry. What I mean is that the Toast doesn't show up. Some typo error on my part.

– rminaj
Mar 22 at 4:58





@Al-Amin sorry. What I mean is that the Toast doesn't show up. Some typo error on my part.

– rminaj
Mar 22 at 4:58












1 Answer
1






active

oldest

votes


















0














Add this in volley



 stringRequest.setRetryPolicy(DefaultRetryPolicy(20000, 3, 1.0f));





share|improve this answer























  • which StringRequest do I put code? I got 2 StringRequest on my app.

    – rminaj
    Mar 22 at 6:51











  • just put above this code:-> queue.add(stringRequest);

    – Urvish Jani
    Mar 22 at 7:11












  • But I don't really need to do a retry after getMessageAds() fails because it doesn't really have anything to get from the server currently.

    – rminaj
    Mar 22 at 7:16











  • It is not for retry only.it is for long request .if your server delay to put some data so you can use this

    – Urvish Jani
    Mar 22 at 9:11











  • Oh, I see. I'll try using that someday

    – rminaj
    Mar 22 at 9:13











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292686%2fandroid-volley-stringrequest-not-working-sometimes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Add this in volley



 stringRequest.setRetryPolicy(DefaultRetryPolicy(20000, 3, 1.0f));





share|improve this answer























  • which StringRequest do I put code? I got 2 StringRequest on my app.

    – rminaj
    Mar 22 at 6:51











  • just put above this code:-> queue.add(stringRequest);

    – Urvish Jani
    Mar 22 at 7:11












  • But I don't really need to do a retry after getMessageAds() fails because it doesn't really have anything to get from the server currently.

    – rminaj
    Mar 22 at 7:16











  • It is not for retry only.it is for long request .if your server delay to put some data so you can use this

    – Urvish Jani
    Mar 22 at 9:11











  • Oh, I see. I'll try using that someday

    – rminaj
    Mar 22 at 9:13















0














Add this in volley



 stringRequest.setRetryPolicy(DefaultRetryPolicy(20000, 3, 1.0f));





share|improve this answer























  • which StringRequest do I put code? I got 2 StringRequest on my app.

    – rminaj
    Mar 22 at 6:51











  • just put above this code:-> queue.add(stringRequest);

    – Urvish Jani
    Mar 22 at 7:11












  • But I don't really need to do a retry after getMessageAds() fails because it doesn't really have anything to get from the server currently.

    – rminaj
    Mar 22 at 7:16











  • It is not for retry only.it is for long request .if your server delay to put some data so you can use this

    – Urvish Jani
    Mar 22 at 9:11











  • Oh, I see. I'll try using that someday

    – rminaj
    Mar 22 at 9:13













0












0








0







Add this in volley



 stringRequest.setRetryPolicy(DefaultRetryPolicy(20000, 3, 1.0f));





share|improve this answer













Add this in volley



 stringRequest.setRetryPolicy(DefaultRetryPolicy(20000, 3, 1.0f));






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 22 at 5:44









Urvish JaniUrvish Jani

173




173












  • which StringRequest do I put code? I got 2 StringRequest on my app.

    – rminaj
    Mar 22 at 6:51











  • just put above this code:-> queue.add(stringRequest);

    – Urvish Jani
    Mar 22 at 7:11












  • But I don't really need to do a retry after getMessageAds() fails because it doesn't really have anything to get from the server currently.

    – rminaj
    Mar 22 at 7:16











  • It is not for retry only.it is for long request .if your server delay to put some data so you can use this

    – Urvish Jani
    Mar 22 at 9:11











  • Oh, I see. I'll try using that someday

    – rminaj
    Mar 22 at 9:13

















  • which StringRequest do I put code? I got 2 StringRequest on my app.

    – rminaj
    Mar 22 at 6:51











  • just put above this code:-> queue.add(stringRequest);

    – Urvish Jani
    Mar 22 at 7:11












  • But I don't really need to do a retry after getMessageAds() fails because it doesn't really have anything to get from the server currently.

    – rminaj
    Mar 22 at 7:16











  • It is not for retry only.it is for long request .if your server delay to put some data so you can use this

    – Urvish Jani
    Mar 22 at 9:11











  • Oh, I see. I'll try using that someday

    – rminaj
    Mar 22 at 9:13
















which StringRequest do I put code? I got 2 StringRequest on my app.

– rminaj
Mar 22 at 6:51





which StringRequest do I put code? I got 2 StringRequest on my app.

– rminaj
Mar 22 at 6:51













just put above this code:-> queue.add(stringRequest);

– Urvish Jani
Mar 22 at 7:11






just put above this code:-> queue.add(stringRequest);

– Urvish Jani
Mar 22 at 7:11














But I don't really need to do a retry after getMessageAds() fails because it doesn't really have anything to get from the server currently.

– rminaj
Mar 22 at 7:16





But I don't really need to do a retry after getMessageAds() fails because it doesn't really have anything to get from the server currently.

– rminaj
Mar 22 at 7:16













It is not for retry only.it is for long request .if your server delay to put some data so you can use this

– Urvish Jani
Mar 22 at 9:11





It is not for retry only.it is for long request .if your server delay to put some data so you can use this

– Urvish Jani
Mar 22 at 9:11













Oh, I see. I'll try using that someday

– rminaj
Mar 22 at 9:13





Oh, I see. I'll try using that someday

– rminaj
Mar 22 at 9:13



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292686%2fandroid-volley-stringrequest-not-working-sometimes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현