I am getting "net::ERR_UNKNOWN_URL_SCHEME" while calling a telephone number option from an HTML page in Android. Do I need to add any permission(s) in the manifest to get this working? I haven't added anything in the manifest so far. Here's the HTML Code:
<a
href="tel:+1800229933">Call us free!</a>
The following should work and not require any permissions in the manifest (basically override shouldOverrideUrlLoading and handle
links separately from tel, mailto, etc.):
mWebView = (WebView) findViewById(R.id.web_view); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if( url.startsWith("http:") || url.startsWith("https:") ) { return false; } // Otherwise allow the OS to handle things like tel, mailto, etc. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity( intent ); return true; } }); mWebView.loadUrl(url);
时间: 2024-10-18 03:19:53