The problem with displaying JavaScript alerts in WebView on Android using Material Design 3 I am working on an Android application that uses WebView to display web content. Everything works well on a smartphone or tablet. But the model(popup) is not displayed in the monoblock(an android device that is mainly used by cashiers and something like that)
This is my code
@SuppressLint("SetJavaScriptEnabled")
@Composable
fun WebViewScreen() {
AndroidView(
factory = { context ->
WebView(context).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
settings.apply {
javaScriptEnabled = true
domStorageEnabled = true
javaScriptCanOpenWindowsAutomatically = true
setSupportMultipleWindows(true)
}
webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?
): Boolean {
return false
}
}
webChromeClient = object : WebChromeClient() {
override fun onJsAlert(
view: WebView?,
url: String?,
message: String?,
result: JsResult?
): Boolean {
result?.confirm()
return true
}
}
loadUrl(PAGE_URL)
}
},
update = {
it.loadUrl(PAGE_URL)
}
)
}