Getting net::ERR_UNKNOWN_URL_SCHEME while calling telephone number from HTML page in Android

来源:互联网 发布:软件编程开发 编辑:程序博客网 时间:2024/04/27 21:23

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.):

[java] view plain copy
  1. mWebView = (WebView) findViewById(R.id.web_view);  
  2.   
  3.     WebSettings webSettings = mWebView.getSettings();  
  4.     webSettings.setJavaScriptEnabled(true);  
  5.   
  6.     mWebView.setWebViewClient(new WebViewClient(){  
  7.         @Override  
  8.         public boolean shouldOverrideUrlLoading(WebView view, String url) {  
  9.             if( url.startsWith("http:") || url.startsWith("https:") ) {  
  10.                 return false;  
  11.             }  
  12.   
  13.             // Otherwise allow the OS to handle things like tel, mailto, etc.  
  14.             Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));  
  15.             startActivity( intent );  
  16.             return true;  
  17.         }  
  18.     });  
  19.     mWebView.loadUrl(url);  

0 0