Android custom event in Javascript EventListener

Is it possible to create an event in Android that sends data to a Havascript EventListener in a WebView?

For example:
In the background, I start the topic of searching for updates on the server. When updates have been found, I send an event to update data on the user page. And I do not want to reload the view.

+3
source share
1 answer

Currently, the only way I found out is to use JavaScript injection:

mWebView.loadUrl("javascript:helloWorld(\"hi\");"); //or postUrl if using HTTP POST

This will call the function helloWorlddefined in the JavaScript of the web page with the parameter hi.

+3
source

All Articles