This error occurs because WebView cannot recognize the URL scheme, for example, WebView usually recognizes http and https, anything but these, for example - intent: //, market: //, app: //, mail: // etc will not be recognized by the web view until we add a handler to process these URL schemes or disable these schemes and only load the http and https schemes.
Here is an example to fix a general purpose URL scheme.
mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return loadUrl(view, url); } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); } @Override public void onReceivedError(WebView view, int errorCode, String description,String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); //Log.d("Web Request Error", ""); showError(errorCode); } @TargetApi(Build.VERSION_CODES.M) @Override public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { super.onReceivedError(view, request, error); Log.d("WebResource error", ""); int errorCode = error.getErrorCode(); showError(errorCode); } }); private boolean loadUrl(WebView view, String url) { if (url.startsWith("http:") || url.startsWith("https:")) { view.loadUrl(url); return false; } // Otherwise allow the OS to handle it else if (url.startsWith("tel:")) { Intent tel = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); startActivity(tel); return true; } else if (url.toLowerCase().startsWith("mailto:")) { MailTo mt = MailTo.parse(url); Intent emailIntent = newEmailIntent(mt.getTo(), mt.getSubject(), mt.getBody(), mt.getCc()); startActivity(emailIntent); return true; } return true; }
source share