WebViewClient.ShouldInterceptRequest example
Example: shouldoverrideurlloading kotlin
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
if (Uri.parse(url).host == getString(R.string.website_domain)) {
return false
}
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
return true
}
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK && webview.canGoBack()) {
webview.goBack()
return true
}
return super.onKeyDown(keyCode, event)
}