From 25b8d360da9c99fb868b6a26da7f62a41b711ae0 Mon Sep 17 00:00:00 2001 From: Ian Clelland Date: Mon, 21 Jul 2014 09:20:49 -0400 Subject: [PATCH] Handle unsupported protocol errors in webview better --- .../org/apache/cordova/CordovaWebViewClient.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java index 4a72feaf..d448be1e 100755 --- a/framework/src/org/apache/cordova/CordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java @@ -259,7 +259,19 @@ public class CordovaWebViewClient extends WebViewClient { // Clear timeout flag this.appView.loadUrlTimeout++; - // Handle error + // If this is a "Protocol Not Supported" error, then revert to the previous + // page. If there was no previous page, then punt. The application's config + // is likely incorrect (start page set to sms: or something like that) + if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) { + if (view.canGoBack()) { + view.goBack(); + return; + } else { + super.onReceivedError(view, errorCode, description, failingUrl); + } + } + + // Handle other errors by passing them to the webview in JS JSONObject data = new JSONObject(); try { data.put("errorCode", errorCode);