android - Why CordovaWebViewClient not working in Cordova 6 anymore -


i have written custom webviewclient class override onpagestarted, onpagefinished etc in cordova 3.7 working fine.

in following code have hosted www directory web server , interacting cordova plugins there (barcodescanner, nfc, bluetooth etc).

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);         }      }  } 

after year, have migrated project cordova 3.7 cordova 6 found above code broken cordovawebviewclient, super.onpagestarted etc can't resolve symbols. tried cordovawebviewimpl , confused myself.

after searching alot on google found solution given in 2011-14 not applicable. couldn't found cordova docs helpful.

it replaced systemwebviewclient

you should this:

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);     } }); 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -