title: How to handle page reload in Cordova/PhoneGap
body: <p>I have a Cordova/PhoneGap application which uses History API. It uses History API as it's shared code between Web and Cordova apps. And mobile webKit looks like it support History API (but actually support is buggy).</p>
  
  <p>So in some place client js-code makes document.location.reload and the current url can be ANY (and differs from initial one). In Cordova app this leads "Application Error:  network error (file:///display/...)". That's because there was history.pushState("/display/..") before.</p>
  
  <p>Indeed I could patch client code where it makes history.pushState, but I woudldn't like to do this. </p>
  
  <p>Instead I want to handle url loading in Cordova Java code and redirect it to loading of "index.html" (main app page in assets/www).</p>
  
  <p><strong>How to do this?</strong></p>
  
  <p>I tried to override CordovaWebViewClient with my own implementation :</p>
  
  <pre><code>    CordovaWebViewClient webViewClient = new MyWebViewClient(this, this.appView);
      this.appView.setWebViewClient(webViewClient);
  </code></pre>
  
  <p>where override shouldOverrideUrlLoading:</p>
  
  <pre><code>public boolean shouldOverrideUrlLoading(WebView webView, String url) {
  
      if (url.startsWith("file:///display/"))
          return true;
  
      return super.shouldOverrideUrlLoading(webView, url);
  }
  </code></pre>
  
  <p>But the method isn't be called on page reload from client js code.</p>