Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Once you create and attach a <code>WebViewClient</code> to your <code>WebView</code>, you have overridden the default behavior where Android will allow the ActivityManager to pass the URL to the browser (this only occurs when no client is set on the view), see <a href="http://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading%28android.webkit.WebView,%20java.lang.String%29" rel="noreferrer">the docs on the method for more</a>.</p> <p>Once you have attached a <code>WebViewClient</code>, returning false form <code>shouldOverrideUrlLoading()</code> passes the url to the <code>WebView</code>, while returning true tells the <code>WebView</code> to do nothing...because your application will take care of it. Unfortunately, neither of those paths leads to letting Android pass the URL to the browser. Something like this should solve your issue:</p> <pre><code>@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { try { URL urlObj = new URL(url); if( TextUtils.equals(urlObj.getHost(),"192.168.1.34") ) { //Allow the WebView in your application to do its thing return false; } else { //Pass it to the system, doesn't match your domain Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); //Tell the WebView you took care of it. return true; } } catch (Exception e) { e.printStackTrace(); } } </code></pre> <p>I know that seems a little counterintuitive as you would expect <code>return false;</code> to completely circumvent the <code>WebView</code>, but this is not the case once you are using a custom <code>WebViewClient</code>.</p> <p>Hope that helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload