I am unable to load content in webview which has data with a hyperlink that comes with the '#' hash code. like below.
<a href="https://safetravel.changiairport.com/#/">here</a>
Full web content is here.
I am loading webview like this way.
binding.webView.loadData(
getHtmlData(viewModel.blogPost.get()!!.formatContentData()),
"text/html",
"UTF-8")
@Parcelize
data class BlogPost(
val title: String,
... remove for brebity
) : Parcelable {
fun formatContentData(): String {
val justifyTag = "<html><body style='text-align:justify;'>%s</body></html>"
content?.let {
var data = it.replace("<", "<").replace(">", ">")
val tagList = arrayOf("flightnode", "hotelnode ", "packagenode")
for (tag in tagList) {
val patternString = "(?is)<$tag[^>]+>.*?<\\/$tag>"
val pattern = Pattern.compile(patternString)
val matcher = pattern.matcher(data)
println("\n\n" + matcher.find())
data = matcher.replaceAll("")
}
return java.lang.String.format(Locale.US, justifyTag, data)
}
return ""
}
}
Any help is appriciated.