I have a webview that I am creating. It seems to automatically be linkifying numbers into tel: urls. I didn't see a way to remove this ability (at least nothing similar to the way to enable it on a textview).
The code is pretty simple:
// populate the web view
WebView webView = (WebView) findViewById(R.id.app_info_webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
webView.setBackgroundColor(0);
String url = APP_INFO_BODY_HTML + "?versionName=" + versionName;
webView.loadUrl(url);
I have a copyright notice at the bottom of the page, android is changing the 2011 into a clickable link that opens the dialer. Also, the App version 1.0.0 opens in the dialer.
Is there a way to disable this functionality?
Update: I just discovered that this seems device dependent...happens on the Droid X, but not a Samsung Captivate, not on Nexus S, and not the emulator.
There is a way to do that - rather ugly, two layered, but still a workaround.
You should
explicitly tell the loaded page not to apply styles and haptic feedback.
mWebView.setWebViewClient( new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, final String url) {
Uri uri = Uri.parse(url);
//TODO analyse the uri here
//and exclude phone and email from triggering any action
return false;
}
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {}
public void onPageFinished (WebView view, String url) {...}
public void onPageStarted(WebView view, String url, Bitmap favicon) {...}
public void onLoadResource(WebView view, String url) {...}
});
In the html specify the following meta tags inside the tag:
<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With