Hi,
I'm trying to add Java objects to a WebView, such that they are
available to Javascript.
I can prove that if I do:
mWebView.addJavascriptInterface(myAvailableAtLoadTimeObject,
"MyJavaObject");
mWebView.load("file:///android_assets/index.html");
I can call methods from Javascript:
MyJavaObject.callableFunction(); // callableFunction is a Java method
on myAvailableAtLoadTimeObject.
or from Java:
mWebView.loadUrl("javascript:MyJavaObject.callableFunction();");
However, if WebViewClient.onPageFinished() has occurred, and then I
try:
mWebView.addJavascriptInterface(myAvailableOnlyLaterObject,
"MyLateJavaObject");
mWebView.loadUrl("javascript:MyLateJavaObject.callableFunction();");
I get an error reported from Javascript:
Uncaught ReferenceError: MyLateJavaObject is not defined
What am I missing, or doing wrong?
Thanks,
James
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en