title: Android WebView app err_unknown_url_scheme (mailto, external links, website internal links)
body: <p>I have used this code and is working correctly (webview links and external links of website) but,</p>
  <p>I get &quot;ERR_UNKNOWN_URL_SCHEME&quot; when trying to tap on html links that starts with mailto:</p>
  <p>*So I need my website links work in webview app, other external links like facebook, instagram, all others... to open from browser android or app, and links like mailto: | tel: to send from app / phone.</p>
  <p>Anyone can help me to fix this please?
  I have little knowledge in java :(</p>
  <p>Thanks.</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  String websiteURL = &quot;https://dwosix.com&quot;; // sets web url
  private WebView webview;
  SwipeRefreshLayout mySwipeRefreshLayout;
  
  @SuppressLint(&quot;SetJavaScriptEnabled&quot;)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      if( ! CheckNetwork.isInternetAvailable(this)) //returns true if internet available
      {
          //if there is no internet do this
          setContentView(R.layout.activity_main);
          //Toast.makeText(this,&quot;No Internet Connection, Chris&quot;,Toast.LENGTH_LONG).show();
  
          new AlertDialog.Builder(this) //alert the person knowing they are about to close
                  .setTitle(&quot;No internet connection available&quot;)
                  .setMessage(&quot;Please Check you're Mobile data or Wifi network.&quot;)
                  .setPositiveButton(&quot;Ok&quot;, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          finish();
                      }
                  })
                  //.setNegativeButton(&quot;No&quot;, null)
                  .show();
  
      }
      else
      {
          //Webview stuff
          webview = findViewById(R.id.webView);
          WebSettings webSettings = webview.getSettings();
          webSettings.setJavaScriptEnabled(true);
          webview.getSettings().setJavaScriptEnabled(true);
          webview.getSettings().setDomStorageEnabled(true);
          webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
          webview.loadUrl(websiteURL);
          webview.setWebViewClient(new WebViewClientDemo(){
              public boolean shouldOverrideUrlLoading(WebView view, String url) {
                  if (url.startsWith(&quot;mailto:&quot;) || url.startsWith(&quot;tel:&quot;)) {
                      view.getContext().startActivity(
                              new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                  } else {
                      // Stay within this webview and load url
                      view.loadUrl(url);
                  }
                  return true;
              }
          });
      }
  
      //Swipe to refresh functionality
      mySwipeRefreshLayout = this.findViewById(R.id.swipeContainer);
  
      mySwipeRefreshLayout.setOnRefreshListener(
              new SwipeRefreshLayout.OnRefreshListener() {
                  @Override
                  public void onRefresh() {
                      webview.reload();
                  }
              }
      );
  }
  
  private class WebViewClientDemo extends WebViewClient {
  
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
          if((String.valueOf(request.getUrl())).contains(&quot;dwosix.com&quot;)) {
              view.loadUrl(String.valueOf(request.getUrl()));
          }
          else {
              view.getContext().startActivity(
                      new Intent(Intent.ACTION_VIEW, request.getUrl()));
          }
          return true;
      }
      @Override
      public void onPageFinished(WebView view, String url) {
          super.onPageFinished(view, url);
          mySwipeRefreshLayout.setRefreshing(false);
      }
  }
  
  //set back button functionality
  @Override
  public void onBackPressed() { //if user presses the back button do this
      if (webview.isFocused() &amp;&amp; webview.canGoBack()) { //check if in webview and the user can go back
          webview.goBack(); //go back in webview
      } else { //do this if the webview cannot go back any further
  
          new AlertDialog.Builder(this) //alert the person knowing they are about to close
                  .setTitle(&quot;EXIT&quot;)
                  .setMessage(&quot;Are you sure. You want to close this app?&quot;)
                  .setPositiveButton(&quot;Yes&quot;, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          finish();
                      }
                  })
                  .setNegativeButton(&quot;No&quot;, null)
                  .show();
      }
  }
  </code></pre>
  <p>}</p>
  <p>class CheckNetwork {</p>
  <pre><code>private static final String TAG = CheckNetwork.class.getSimpleName();
  
  public static boolean isInternetAvailable(Context context)
  {
      NetworkInfo info = ((ConnectivityManager)
              context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
  
      if (info == null)
      {
          Log.d(TAG,&quot;no internet connection&quot;);
          return false;
      }
      else
      {
          if(info.isConnected())
          {
              Log.d(TAG,&quot; internet connection available...&quot;);
          }
          else
          {
              Log.d(TAG,&quot; internet connection&quot;);
          }
          return true;
  
      }
  }
  </code></pre>
  <p>}</p>