Set loadURLTImeOutValue on WebView
This is a workaround to simulate the described behavior. You can use a WebViewClient
, and override the onPageStarted
method:
public class MyWebViewClient extends WebViewClient {
boolean timeout;
public MyWebViewClient() {
timeout = true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
new Thread(new Runnable() {
@Override
public void run() {
timeout = true;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(timeout) {
// do what you want
}
}
}).start();
}
@Override
public void onPageFinished(WebView view, String url) {
timeout = false;
}
}
If timeout, you can load, for example, an error page...
To add the WebViewClient
to you WebView
, just do this:
webView.setWebViewClient(new MyWebViewClient());
Android WebView TimeOut
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.
WebView Timeout Issue while accessing an AD authenticated website
Finally got it working with this:
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
if(webView.getProgress()==100)
{
timeout = false;
}
}
Referred from this link:
Android WebView TimeOut
Cordova webview TIMEOUT ERROR
Ok I did it this way: set loadURLTImeOutValue on webview
i.e. adding intent.putExtra("loadUrlTimeoutValue", 60000); to every call to the activity that extends CordovaInterface.
Cordova WebView TIMEOUT ERROR with android
You're not doing anything wrong, the TIMEOUT ERROR probably occurs because your Android phone (or your emulator) runs too slow.
You can try to increase the load timeout with the following instruction :
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
in your OnCreate method. Or set it in the config.xml file :
<preference name="loadUrlTimeoutValue" value="60000" />
Related Topics
Transfer Data from One Activity to Another Activity Using Intents
How to Make Zoomable Linearlayout
Cordova - Error: Failed to Fetch Platform Android
Getactionview() of My Menuitem Return Null
What Are the Overheads of Using Autoincrement for SQLite on Android
Failure [Install_Failed_Update_Incompatible] Even If App Appears to Not Be Installed
Android Navigation Drawer on Top Actionbar
Android Disable Screen Timeout While App Is Running
How to Use Sms Content Provider? Where Are the Docs
Single Observable with Multiple Subscribers
Android:Understanding Drawable Folder
Cannot Call Getsupportfragmentmanager() from Activity
Firebase Token Authentication Error
Multiple Dex Files Define Lcom/Google/Android/Gms/Internal/Zzau