我已经编写了自定义webvIEwclIEnt类来覆盖cordova 3.7中的onPageStarted,onPageFinished等,它工作正常.
在下面的代码中,我已经将www目录托管到Web服务器并从那里交互cordova插件(条形码扫描器,nfc,蓝牙等).
public class MainActivity extends CordovaActivity { private WebVIEw webVIEw; @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.init(); loadUrl("https://example.com"); } public class CustomCordovaWebVIEwClIEnt extends CordovaWebVIEwClIEnt { public CustomCordovaWebVIEwClIEnt(CordovaInterface cordova, CordovaWebVIEw vIEw) { super(cordova, vIEw); } @OverrIDe public voID onPageStarted(WebVIEw vIEw, String url, Bitmap favicon) { super.onPageStarted(vIEw, url, favicon); Log.i("CSP Log", "onPageStarted: " + url); } @OverrIDe public voID onPageFinished(WebVIEw vIEw, String url) { super.onPageFinished(vIEw, url); Log.i("CSP Log", "onPageFinished: " + url); } @OverrIDe public voID doUpdateVisitedHistory(WebVIEw vIEw, String url, boolean isReload){ super.doUpdateVisitedHistory(vIEw, url, isReload); } @OverrIDe public voID onReceivedError(WebVIEw vIEw, int errorCode, String description, String failingUrl) { super.onReceivedError(vIEw, errorCode, description, failingUrl); } }}
一年后,我将项目从cordova 3.7迁移到cordova 6,但我发现上面的代码像CordovaWebVIEwClIEnt一样被破坏,super.onPageStarted等无法解析符号.我也尝试过CordovaWebVIEwImpl并迷惑自己.
在Google上搜索了很多我发现的解决方案,这些解决方案主要在2011-14中给出,不适用.我找不到cordova文档有用.
解决方法:
它被SystemWebVIEwClIEnt取代
你应该做这样的事情:
SystemWebVIEw wv = (SystemWebVIEw)appVIEw.getVIEw();wv.setWebVIEwClIEnt(new SystemWebVIEwClIEnt((SystemWebVIEwEngine)appVIEw.getEngine()){ @OverrIDe public voID onPageStarted(WebVIEw vIEw, String url, Bitmap favicon) { super.onPageStarted(vIEw, url, favicon); Log.i("CSP Log", "onPageStarted: " + url); } @OverrIDe public voID onPageFinished(WebVIEw vIEw, String url) { super.onPageFinished(vIEw, url); Log.i("CSP Log", "onPageFinished: " + url); } @OverrIDe public voID doUpdateVisitedHistory(WebVIEw vIEw, String url, boolean isReload){ super.doUpdateVisitedHistory(vIEw, url, isReload); } @OverrIDe public voID onReceivedError(WebVIEw vIEw, int errorCode, String description, String failingUrl) { super.onReceivedError(vIEw, errorCode, description, failingUrl); }});
总结 以上是内存溢出为你收集整理的android – 为什么CordovaWebViewClient不再在Cordova 6中工作了全部内容,希望文章能够帮你解决android – 为什么CordovaWebViewClient不再在Cordova 6中工作了所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)