Reputation: 3833
I am developing a html webpage for show in an android/ios/windows phone app inside a webview.
I have this kind of links: and the same with mailto:"[email protected]"
In ios works fine, also in chrome, firefox... But in webviews's webbrowser in android detects it as normal link and shows an inexistent webpage (This url cannot be found bla bla bla)
Is there a way to avoid this in android? or should I detect browser in javascript and load the href or not?
I found this for javascript: var browser = navigator.appName;
But I read this is not a good practice.
Upvotes: 0
Views: 624
Reputation: 47817
Disable the automatic Linkify of Webview
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);
if (url.startsWith("http:") || url.startsWith("https:")) {
return false;
}
//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.
Upvotes: 1