title: WebView - load links in external browser
body: <p>I am loading the content of a locally stored <code>HTML</code> file in a <code>WebView</code> in my app. This file also contains links inside it, which when clicked, load the <code>URLs</code> in the same <code>WebView</code>. I want to load these links in an external browser instead. I have taken a look at <code>onPageStarted</code> and <code>shouldOverrideUrlLoading</code>, but they don't seem to work. I have tried the following:</p>
  
  <pre><code>    webAbout = (WebView) findViewById(R.id.wvAbout);
      webAbout.loadUrl(Const.defURL);
  
      webAbout.setWebViewClient(new WebViewClient() {  
            @Override  
            public void onPageStarted(WebView view, String url, Bitmap favicon){  
              if (!url.startsWith(Const.defURL)) { 
                view.stopLoading();  
                // DO SOMETHING  
              }else{
                  view.loadUrl(Const.defURL);
              }
            }  
          });
  </code></pre>
  
  <p>I have also tried:</p>
  
  <pre><code>    webAbout = (WebView) findViewById(R.id.wvAbout);
      webAbout.loadUrl(Const.defURL);
  
       webAbout.setWebViewClient(new WebViewClient(){
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
  
              if (url != null &amp;&amp; (url.startsWith(Const.defURL))){
  
                  webAbout.loadUrl(Const.defURL);
                  return true;
                  } 
  
            else  {
  
                  view.getContext().startActivity(
                  new Intent(Intent.ACTION_VIEW, Uri.parse(url)));  
                  return false;
            }
          }
      });
  </code></pre>
  
  <p>but in both cases, the <code>WebView</code> does not load anything. Any idea where I am going wrong?</p>