I have a function drawImage(json, check) in file test.js. ow I want to call this function from android code. I use cwv.loadUrl("javascript:test.drawImage("+jsonArray+","+ true+")");, but this solution doesn't work. How can I call this method from android code?
-
stackoverflow.com/a/7544818/1276374Boris Mocialov– Boris Mocialov2013-08-07 06:54:10 +00:00Commented Aug 7, 2013 at 6:54
Add a comment
|
1 Answer
You can put you JS function not in external file. Insted of it put it in your html file like this:
<script>
function drawImage ()
{
// your computataion
}
</script>
// or connect your js functions from external file
<script src="test.js"></script>
And then call it from code
cwv.loadUrl("javascript:drawImage('"+jsonArray+"','"+ true+"')");
And pay attention to single quotation!
And the second mothod was described by Mocialov Boris.
2 Comments
edi233
I must have this method in external file. Can you tell me how can I do that in that way?
Sergey Brazhnik
I've edited my answer. Look above