美文网首页
使用webview调用H5支付,直接跳转微信或支付宝

使用webview调用H5支付,直接跳转微信或支付宝

作者: Kingsley_Wu | 来源:发表于2020-10-11 20:55 被阅读0次
    // 使用webview调用H5支付,直接跳转微信或支付宝
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String url) {
            if (url.contains("weixin://") || url.contains("alipays://") || url.contains("tel:")) {
                try {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                    return true;
                    //防止没有app匹配到action时抛出异常闪返
                } catch (Exception ignored) {}
            }
            return super.shouldOverrideUrlLoading(webView, url);
        }
    });

相关文章

网友评论

      本文标题:使用webview调用H5支付,直接跳转微信或支付宝

      本文链接:https://www.haomeiwen.com/subject/pacwlktx.html