Android webview 调起H5微信支付

mWebView.setWebViewClient(new MyWebViewClient());
private class MyWebViewClient extends WebViewClient 
{
    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) 
    {
        try 
        {
            if (url.startsWith("weixin://wap/pay?")) 
            {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
            }
        }
        catch (Exception e) 
        {
            e.printStackTrace();
            //调起微信页面失败,自己看着办...
        }
        super.onPageStarted(view, url, favicon);
    }
 
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
    {
        //高版本可以在这里拦截,but低版本这里不会每次都调用!
        //根据测试Android 6.0在这拦截无效
        return super.shouldOverrideUrlLoading(view, request);
    }
}

 

posted @ 2019-01-25 10:01  一个人的孤独自白  阅读(3866)  评论(0编辑  收藏  举报