alipay / mPaaS

mPaaS Demo 合集,mPaaS 是源自于支付宝的移动开发平台。The collection of demos for mPaaS components. mPaaS is the Mobile Development Platform which oriented from Alipay.
https://tech.antfin.com/docs/2/49549
Apache License 2.0
324 stars 55 forks source link

android H5容器如何设置WebViewClient和WebChromeClient? #32

Closed wu19910708 closed 4 years ago

wu19910708 commented 4 years ago

我们项目现在需要单独写一套自己的JSBridge,所以会涉及到JS注入的时机问题,然后APWebView如何转成android webkit的WebView

SpinyTech commented 4 years ago
  1. 注册自定义 JSAPI 插件,监听 CommonEvents.H5_PAGE_START
  2. 在自定义 JSAPI 的 handleEvent 中,拿到 h5page 实例,
  3. 通过调用 h5page.getWebView().setWebViewClient 和 setWebChromeClient 来完成设置

注意: 设置的内容要继承 APWebViewClient 和 APWebChromeClient,和 google 原生的接口是一致的。