0

I have such HTML

<body>
  <p>https://www.google.com</p>
  <p>foo@bar.com</p>
</body>

Is there any way to tell WebView to auto linkify content, and render like if it was:

<body>
  <p><a href="https://www.google.com">https://www.google.com</a></p>
  <p><a href="mailto:foo@bar.com">foo@bar.com</a></p>
</body>
alex2k8
  • 42,496
  • 57
  • 170
  • 221
  • 1
    possible duplicate of [Is there any way to have WebView auto-link URLs and phone numbers in Android?](http://stackoverflow.com/questions/1744091/is-there-any-way-to-have-webview-auto-link-urls-and-phone-numbers-in-android). Please check the answer by Harri and the comment to it by azdev. – cygery Aug 17 '14 at 11:19
  • There are some other questions on SO but they ask opposite - how to disalbe auto-detection of the links. This is why I still wonder to see any easy way to enable auto-detection in WebView... See this post for example http://stackoverflow.com/questions/5472547/disable-the-automatic-linkify-of-webview Also they refere to in Android sources having CacheBuilder.cpp - FindPartialAddress, FindPartialEMail, FindPartialNumber - that also seems to be related to links auto-detection. – alex2k8 Aug 17 '14 at 11:37

1 Answers1

1

Short answer: No. WebView is a web browser, so it will render a html page. Your html page does not include links, so why would WebView alter it?

Long Answer: You can intercept the page loading using a WebViewClient then inject a javascript that linkifies the page. There are tons of JQuery-based scripts around. But mind that this method won't be bullet-proof and will depend on the loaded page structure. For something as simple as your example it will be very easy, but if you add HTML5 , dynamic content, Iframes, asynchronous content ... things start to get complicated.

rupps
  • 9,712
  • 4
  • 55
  • 95