Reputation: 677
I am using Accompanist library to implement WebView changes in Android Jetpack Compose.
https://google.github.io/accompanist/web/
WebView(
state = state,
modifier = Modifier.weight(1f),
onCreated = { webView ->
webView.settings.javaScriptEnabled = true
},
client = webClient
)
I am not seeing any examples to add addJavascriptInterface to intercept toggle on/off interactions from WebView page.
Is this is possible with AccompanistWebView?
Upvotes: 0
Views: 911
Reputation: 132
you can use console messages to observer actions, on the webView:
val currentWebView: WebView? = null
WebView(
state = state,
modifier = Modifier.weight(1f),
onCreated = { webView ->
currentWebView = webView
webView.settings.javaScriptEnabled = true
},
client = webClient
)
currentWebView?.webChromeClient = object : WebChromeClient() {
override fun onConsoleMessage(consoleMessage: ConsoleMessage):Boolean {
// Observer messages here
return true
}
}
Upvotes: 1