Issue
I'm trying to do something a little tricky. I have an activity which has a webView inside. This web view is loading an external html file which has some javascript functions.
My activity is producing some reults periodically and I want to access these results in javascript functions. I thought writing output results to a file and reading in javascript side might be a solution. But I'm not sure about it.
Is there a way for doing sth like this ?
I know that we can navigate to android functions from javascript, but it is not exactly what I need.
Thanks..
Solution
If you need the results only once, and on the fly, then you could try not to write them to a file but to inject it to the WebView as javascript. For example in your page you could add a function:
function newData(jsonObj) {
...
}
and instead of writing to a file you would call this with your actual data.
webview.loadUrl("javascript:(newData({a:1, b:2,...}))");
Answered By - Gavriel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.