Apache Cordova
  1. Apache Cordova
  2. CB-955

CordovaWebViewClient shouldOverrideUrlLoading method not called upon a redirect

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.8.1
    • Fix Version/s: 2.1.0
    • Component/s: Android
    • Labels:
      None
    • Environment:
      • Android 4.0 emulator running in windows machine as well in iOS machine
      • Android 2.3 device.

      Description

      Summary
      -------
      in Cordova v 1.8.1 a DroidGap.appview's CordovaWebViewClient.shouldOverrideUrlLoading method is not called when that appview loads a URL that results in a redirect.

      To reproduce
      ------------

      • create a DroidGap activity and set instance of CordovaWebViewClient as DroidGap.appview's WebViewClient.
      • override shouldOverrideUrlLoading
      • have the DroidGap.appview load a URL that redirects to another page

      Sample code (from within an Activity subclass):

      public class HelloPhoneGapActivity extends DroidGap {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
      try{
      super.onCreate(savedInstanceState);
      super.init();
      super.appView.clearCache(true);
      super.appView.clearHistory();

      this.appView.setWebViewClient(new CordovaWebViewClient(this){

      public boolean shouldOverrideUrlLoading(final WebView view, String url)

      { Log.i("BugTest", "shouldOverrideUrlLoading: " + url); return true; }

      public void onPageStarted(WebView view, String url, Bitmap favicon)

      { Log.i("BugTest", "onPageStarted: " + url); }

      public void onPageFinished(WebView view, String url)

      { Log.i("BugTest", "onPageFinished: " + url); }

      });
      super.loadUrl(("http://google.com");

      Actual behavior
      ---------------
      The following is logged:

      INFO/BugTest(14658): onPageStarted: http://google.com/
      INFO/BugTest(14658): onPageStarted: http://www.google.com/
      INFO/BugTest(14658): onPageFinished: http://www.google.com/

      Expected Behavior
      -----------------
      On devices running with cordova 1.8.1 (Android OS version 4.0), the following is logged:

      INFO/BugTest(11447): onPageStarted: http://google.com/
      INFO/BugTest(11447): onPageStarted: http://www.google.com/
      INFO/BugTest(11447): shouldOverrideUrlLoading: http://www.google.com/
      INFO/BugTest(11447): onPageFinished: http://www.google.com/

        Activity

          People

          • Assignee:
            Joe Bowser
            Reporter:
            Vaduganathan
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development