title: WebView handle redirect click link with Intent.ACTION_VIEW
body: <p>I've a difficult managing open link on <code>webview</code> content click with <code>Intent.ACTION_VIEW</code> on different device.</p>
  
  <p>My scenario is: i've some html code displayed within a <code>webview</code> inside my app, this content have some link (href), then on click event i want to open the link with external app and not inside the same web view.</p>
  
  <p>I've achieved this by:</p>
  
  <pre><code>webview.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
          Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(request.getUrl().toString()));
          activity.startActivity(intent);    
          return true;
      }
  });
  </code></pre>
  
  <p>So, the problem is that this doesn't happen an all devices.</p>
  
  <p>With Android 7 it's working but on version 6 doesn't. Anyway to manage different version i've already used different implementation.</p>
  
  <pre><code>webview.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
          Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
          activity.startActivity(intent);
          return true;
      }
  });
  </code></pre>
  
  <p>I've already look around on stackoverflow but the only answer i've found it's to use the code above.</p>
  
  <p>Thanks for the support</p>
  
  <p><strong>UPDATE - 15/02/18</strong>
  I've solved the problem, putting the two <code>@Override</code> method together like this:</p>
  
  <pre><code>webview.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
          Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(request.getUrl().toString()));
          activity.startActivity(intent);    
          return true;
      }
  
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
          Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
          activity.startActivity(intent);
          return true;
      }
  });
  </code></pre>