JsBridge 开源库

JsBridge 开源库

项目地址:https://github.com/lzyzsd/JsBridge
使用参考:https://www.jianshu.com/p/7aea03838f19

0x00 从H5界面,跳转Native登录,登录之后重新加载H5页面出现JsBridge注入失败[code=-2,message=net::ERR_NAME_NOT_RESOLVED]

解决方案:
App层销毁当前的WebView,重新加载一个新的WebView去loadUrl。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// js-bridge register error
// 回调 onReceivedError(WebView view, WebResourceRequest request, WebResourceError error)
// [code=-2,message=net::ERR_NAME_NOT_RESOLVED]
// so you have to destroy webView and rebuild one.
private void reloadWebView() {
if (mWebView != null) {
mWebView.destroy();
mWebView = null;
}

initView();
initWebView();
webView.loadUrl(url);
}
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×