Is there a way to set the timeout value in WebView
? I want the WebView to be time-outed if the url is too slow to response or if the site doesn't load in 10 seconds.
I don't know really where I should start :(
I have 2 classes, the first one is starter and the second one is for webView
. Starter is a kind of thread and splash-screen for start and the next activity is the main webView
, so I would like to add a checker if the site doesn't response in 4 10 secs, it would give a error.
I hope any of you can help me,
You can do it by setting up a Timer which checks for progress of current page by calling getProgress() and if it is less than some threshold after some specified time then you can dismiss the loading of the current page.
Darpans code will not work, not at least because the parameter progress will not change during
while
, only by next call of. Try this instead:Unfortunately this will only work if the connection to the server will be established. If not the
onProgressChanged
get called only two times: at 10 and at 100 percents when then load is aborted.Here is the code to implement a timer that will check the progress and triggers action if it takes more than a certain time to load the page.