简体   繁体   English

Android webview tel:0000 无法加载,因为 net:ERR

[英]Android webview tel:0000 could not be loaded because net:ERR

I am building an android application.我正在构建一个 android 应用程序。 I am showing external webpage in webview.我在 webview 中显示外部网页。 I have followed these steps:我已按照以下步骤操作:

  1. Load external website in webview.在 webview 中加载外部网站。 For example example.com, it loads fine in webview例如 example.com,它在 webview 中加载正常
  2. There is an option in example.com site to launch Dialer app on button click. example.com 站点中有一个选项可以在单击按钮时启动拨号器应用程序。 Here is the code.这是代码。

     <div class="center"> <input type="image" src="btn.png" onclick="location.href='tel:0000';"/> </div>
  3. When I go to example.com from mobile browser and click on button, it can launch Dialer app with phone number当我从移动浏览器转到 example.com 并单击按钮时,它可以启动带有电话号码的拨号器应用程序

  4. When I click from webview it shows this error当我从 webview 单击时,它显示此错误

    Web page not available The web page at tel:0000 could not be loaded because: net::ERR_UNKNOWN_URL_SCHEME

I do not know what is went wrong.我不知道出了什么问题。 Any clue will be helpfull.任何线索都会有所帮助。

NB: I am using real phone number (here it is 0000).注意:我使用的是真实电话号码(这里是 0000)。

Thank you谢谢

You should set a WebViewClient to the WebView and than override shouldOverrideUrlLoading method as follow:您应该将 WebViewClient 设置为 WebView,而不是重写 shouldOverrideUrlLoading 方法,如下所示:

myWebView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
            if (request.getUrl().toString().startsWith("tel:")) {
                Intent intent = new Intent(Intent.ACTION_DIAL, request.getUrl());
                view.getContext().startActivity(intent);
            }
            return super.shouldOverrideUrlLoading(view, request);
        }
    });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 网页不可用无法加载位于tel:0000的网页,因为:net :: ERR_UNKNOWN_URL_SCHEME - Web page not available The web page at tel:0000 could not be loaded because: net::ERR_UNKNOWN_URL_SCHEME Android Studio 中的 webview 出现错误“”网页无法加载,因为 net::ERR_ACCESS_DENIED“” - webview in Android Studio with error “”webpage could not be loaded because net:: ERR_ACCESS_DENIED“” 由于 ERR_CLEARTEXT_NOT_PERMITTED,Android Webview 页面无法加载 HTTP 超链接 - Android Webview page could not be loaded with HTTP hyperlink because ERR_CLEARTEXT_NOT_PERMITTED Android上的类星体错误:ip:port的网页无法加载,因为net :: ERR_ADDRESS_UNREACHABLE - Quasar Error on Android: webpage at ip:port could not be loaded because net::ERR_ADDRESS_UNREACHABLE 无法加载位于 file:///android_asset/file.html 的网页,因为:net::ERR_FILE_NOT_FOUND - The webpage at file:///android_asset/file.html could not be loaded because: net::ERR_FILE_NOT_FOUND Android WebView,错误 net::Name_Not_Resolved - Android WebView, err net::Name_Not_Resolved Android WebView:电话:地理位置:Mailto:正确处理 - Android WebView: Tel: Geo: Mailto: Proper Handling Android Webview 给出 net::ERR_CACHE_MISS 消息 - Android Webview gives net::ERR_CACHE_MISS message Android:webview:获取错误代码 -6 net::ERR_CONNECTION_REFUSED - Android : webview : getting error code -6 net::ERR_CONNECTION_REFUSED Android Webview.net::ERR_UNKNOWN_URL_SCHEME - Android Webview net::ERR_UNKNOWN_URL_SCHEME
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM