Search code examples
androidcordovawebviewapache-cordova

Upgrading from Cordova < 4: Current alternative for CordovaXXClients


I'm upgrading some legacy Cordova 2.x and 3.x apps to version 5.1.0. In the old projects the WebView was customized using the now gone CordovaChromeClient and CordovaWebViewClient classes.

Is there a replacement for these classes in the new API?

In particular, I'd like to:

  • Set a higher database quota for SQLite. This was done in the old times calling WebView.setWebChromeClient and passing as parameter an instance of CordovaChromeClient with its onExceededDatabaseQuota method overridden.
  • Override URL loading. This was done in Cordova 3.x and lower calling WebView.setWebViewClient and passing as parameter an instance of CordovaWebViewClient with its shouldOverrideUrlLoading method overridden.

Solution

  • The old CordovaWebViewClient is now the SystemWebViewClient

    The old CordovaChromeClient is now the SystemWebChromeClient

    To get the SystemWebView use the getView and cast it

    ((SystemWebView)appView.getView())