Android: Best way to override shouldOverrideUrlLoading in CordovaWebViewClient

717 views
Skip to first unread message

elsigh

unread,
Dec 18, 2012, 7:04:01 PM12/18/12
to phon...@googlegroups.com
I need to override shouldOverrideUrlLoading so that my app never does a geo intent popup (see related: https://groups.google.com/forum/?fromgroups=#!topic/phonegap/EVPterwpQ1U)

Is there a best way to do this?

Currently, I'm doing:
@Override
  public void init() {
    CordovaWebView webView = new CordovaWebView(TwistDroidActivity.this);
    CordovaWebViewClient webViewClient;
    webViewClient = new IceCreamCordovaWebViewClient(this, webView) {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        Log.d(LOG_TAG, "URLLL: " + url);
        return true;
      }
    };
    this.init(webView, webViewClient, new CordovaChromeClient(this, webView));
  }

But this seems like I may miss out on future logic changes with regards to the WebViewClient (I already cut out the non IceCreamCordovaWebViewClient because we're ICS+.

Advice?

elsigh

unread,
Dec 18, 2012, 10:17:49 PM12/18/12
to phon...@googlegroups.com
The code, as I pasted it, won't of course work ;0

I ended up making another class that extends IceCreamCordovaWebViewClient and now just have:

@Override
  public void init() {
    CordovaWebView webView = new CordovaWebView(TwistDroidActivity.this);
    TwistWebViewClient webViewClient = new TwistWebViewClient(this, webView);
    CordovaChromeClient chromeClient = new CordovaChromeClient(this, webView);
    this.init(webView, webViewClient, chromeClient);
  }


But still, this seems less than ideal insofar as I lost the abstraction around CordovaWebViewClient and IceCreamCordovaWebViewClient.
Reply all
Reply to author
Forward
0 new messages