android webview拉起微信h5支付错误解决办法
2018-01-10 14:05
1301 查看
这里坑比较深.网上说的方式也大多没有用.不废话带你解决
1.遇到的问题大概就"商家参数错误";"空白页";"系统繁忙"等等吧2.问题解决:商家参数错误就是因为没有加Map载loadUrl时候要配置一个Map.key是指定的,url是授权域名
Map<Sting,String> map = new HashMap<>();
map.put("Referer", "http://......");
3.直接用webview去load部分机型可行,因为内核限制的就不行了
4.最终解决方式如下
Map<String, String> map = new HashMap<>(); map.put("Referer","http://...."); WebView webView = ((WebView) findViewById(R.id.webview)); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDefaultTextEncodingName("UTF-8"); webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webView.setWebChromeClient(new WebChromeClient()); WebViewClient webViewClient = new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // 如下方案可在非微信内部WebView的H5页面中调出微信支付 if (url.startsWith("weixin://wap/pay?")) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); return true; } else { Map<String, String> extraHeaders = new HashMap<String, String>(); extraHeaders.put("Referer", "http://wxpay.wxutil.com"); view.loadUrl(url, extraHeaders); } return true; } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, android.net.http.SslError error) { // 重写此方法可以让webview处理https请求 handler.proceed(); } }; webView.setWebViewClient(webViewClient); webView.loadUrl("https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=...", map);
相关文章推荐
- android webview Not allowed to load local resource错误的解决办法
- android webview加载H5页面丢失cookie信息的解决办法
- android webview 调用微信 h5 支付方式
- Android WebView 微信和支付宝H5调用本地app支付
- Android webview 遇到android.os.FileUriExposedException错误解决办法
- webview在设置放大缩小功能时,android.widget.ZoomButtonsController错误解决办法
- android webview Not allowed to load local resource错误的解决办法
- 【Android】4.04系统WebView播放不了Flash问题的解决办法
- android编程中遇到的Caused by: android.view.InflateException: Binary XML file line #13错误的原因及解决办法
- android SurfaceView初次使用错误解决办法 (二)
- 关于android webview中访问web页面带有upload上传控件的解决办法
- android中HttpClient获取Session然后使用 WebView共享session的解决办法(转)
- 【Android】4.04系统WebView播放不了Flash问题的解决办法
- android.webkit.WebView 使用 SINGLE_COLUMN layout algorithm 导致程序意外退出的解决办法
- Android中 View not attached to window manager错误的解决办法
- android.webkit.WebView 使用 SINGLE_COLUMN layout algorithm 导致程序意外退出的解决办法
- Android 使用webview 打不开网页的解决办法
- android webview js alert对话框 不能弹出 解决办法
- 举例说明android编程中遇到的关于android.view.InflateException错误的原因及解决办法
- Android中 View not attached to window manager错误的解决办法