Question

I've got several Activities, that need to access JS code, running in WebView. I need that JS code and it's state to be accessible from everywhere, so I was thinking maybe I can run Webkit engine in my application class, and supply data from it to webview and to other components of my app?

Was it helpful?

Solution

What about moving all general accessible state to a javascript interface in java which you register using the javascript bridge:

    webView.addJavascriptInterface(new JsBridge(), "jsbridge");

I use this to transfer data from javascript to my android/java code and back. It doesn't offer a generic interface to access all data but maybe that's still sufficient.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top