【问题标题】:Unknow URL Scheme from webView "tel:"来自 webView \"tel:\" 的未知 URL 方案
【发布时间】:2022-08-19 16:31:56
【问题描述】:

英俊

我试图从 webview 意图“action_dial”。它并不完美。 当我单击“href tag”时,它会打开错误页面,然后也调用拨号页面。 错误页面消息是 \"unknown_url_scheme\"。请帮我

这是我的代码

<a href= \"tel:02-6285-0085\"> 02-6285-0085</a>

安卓

    webview.setWebViewClient((WebViewClient) (new WebViewClient() {
    public boolean shouldOverrideUrlLoading(@NotNull WebView view, @NotNull WebResourceRequest request) {
     Uri uri = request.getUrl();               
     if (uri.getScheme().equals(\"tel\")){
               
                try {
                    Intent intent = new Intent(Intent.ACTION_DIAL, uri);
                    startActivity(intent); //
                }catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            return false;
        }

    }));

    标签: android html webview href action


    【解决方案1】:

    如果当前代码中的条件需要更改,请尝试一次。

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.startsWith("tel:")) { 
            try {
                        Intent intent = new Intent(Intent.ACTION_DIAL, uri);
                        startActivity(intent); //
                    }catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
             }
        return false;
    }
    

    【讨论】:

      猜你喜欢
      • 2019-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-09
      • 1970-01-01
      相关资源
      最近更新 更多