Can't catch ERROR TIMEOUT with Cordova Android 3.6.3

After migrating from Cordova from 3.4.0 to 3.6.3, it now seems impossible to catch the TIMEOUT ERROR in my activity (when my website is not responding, for example). The 3.5 release notes added a new behavior "Ignore multiple onPageFinished () and onReceivedError callbacks due to stopLoading ()" and seems to be the cause. Carefully examining the source code of the 3.6.3 CordovaWebView java class, when the loadUrlIntoView method is called, if we encounter the "Timeout error" method, we have:

public void run() {
me.stopLoading();
LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!");
if (viewClient != null)
{ viewClient.onReceivedError(me, -6, "The connection to the server was unsuccessful.", url); }

}

      

but the line me.stopLoading();

does: viewClient.isCurrentlyLoading = false;

and when the line viewClient.onReceivedError(me, -6, "The connection to the server was unsuccessful.", url);

is called, the onReceivedError

java CordovaWebViewClient class method is called, but ignores the error due to stopLoading()

:

if (!isCurrentlyLoading)
{ return; }

      

So this method is returned and super.onReceivedError()

never called ... and there is no way to catch TIME OUT to display a specific page.

Please help, Amp

+3


source to share





All Articles