You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good afternoon! I need to use this webview to make sms links open in the message application. I was given a sample code on kotlin. Please tell me how I can change this webview so that everything works for me.
webView.webViewClient =object:WebViewClient() {
overridefunshouldOverrideUrlLoading(
view:WebView?,
request:WebResourceRequest?,
): Boolean {
if (request?.url ==null|| request.url.toString().contains("http://") || request.url.toString().contains("https://"))
returnfalsereturntry {
var uri = request.url.toString()
if (request.url.toString().contains("sms"))
uri = request.url.toString().replaceFirst("(?<=sms:)/{2}".toRegex(), "")
Intent(Intent.ACTION_VIEW, Uri.parse(uri)).also { startActivity(it) }
true
} catch (e:Exception) {
true
}
}
}
or maybe there is an opportunity to do this in the next commit?
The text was updated successfully, but these errors were encountered:
uri = request.url.toString().replaceFirst("(?<=sms:)/{2}".toRegex(), "")
This url correction seems to convert sms://0123456789 to sms:0123456789. The former is wrong and should not be used, but if you still need to correct it, you can utilize the ld: callback to fix such wrong links, for example:
Good afternoon! I need to use this webview to make sms links open in the message application. I was given a sample code on kotlin. Please tell me how I can change this webview so that everything works for me.
or maybe there is an opportunity to do this in the next commit?
The text was updated successfully, but these errors were encountered: