Android WebView "tel:" links show web page not found

OK so I solved the issue I think. I just needed to separate the URL overrides as follows:

public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (url.startsWith("tel:")) { 
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); 
        startActivity(intent);
        view.reload();
        return true;
    }

    view.loadUrl(url);
    return true;
}

Now my regular links work as well as the tel links. I can also add in there for geo: links if I need to and it will not give me the issue that I was having before to open up maps on the phone.


Rather than call loadUrl(url), just return false for the URLs that should not be overridden:

public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if( URLUtil.isNetworkUrl(url) ) {
        return false;
    }

    // Otherwise allow the OS to handle it
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    startActivity( intent ); 
    return true;
}

I've found VIEWing tel: works as expected on all phones we've tried it with. No need to special-case it because of the DIAL action.

I've noticed YouTube videos and the like don't work in WebViews, so you may want to detect those as well.

The whole process could probably be generalized for all sorts of URIs by querying the PackageManager for Activities that handle your URI that are also not the embedded browser. That might be overkill and get confused by other installed browsers.