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

2020-10-11  本文已影响0人  Kingsley_Wu
    // 使用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);
        }
    });
上一篇 下一篇

猜你喜欢

热点阅读