Thanks, Sukumar

My understanding is that MyLateJavaObject is not represented in
Javascript as an object, so there are limited things we can do with
it. From experimentation:

e.g. you can do this:
var obj = MyJavaObject;
obj.method();

But not this:
var fn = MyJavaObject.method;
method();

It does not exist on the window object:
assert.ok(!window.MyLateJavaObject);
assert.equal('undefined', typeof window.MyLateJavaObject);

I'm not aware of any global object (other than window) in this
implementation of Webkit.

I have not tried finding window.MyJavaObject, which was added before
onPageFinished.

Regards, etc

James



On Jan 21, 5:00 am, sukumar bhashyam <bhashyam.suku...@gmail.com>
wrote:
> Try this...
>
>  mWebView.loadUrl("javascript:window.MyLateJavaObject.callableFunction();");
>
> On Thu, Jan 20, 2011 at 11:13 PM, jamesh <jameshug...@gmail.com> wrote:
> > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to