Here is what I am trying to do.
I have a Javascript (JS) given to me, which I can not change.
<html>
<head>
<script type="text/javascript" language="JavaScript">
  var nFindAPITries = 0;
  var API = null;
  function FindAPI(win) {
    while ((win.API == null) && (win.parent != null) && (win.parent !=
win)) {
      nFindAPITries ++;
      if (nFindAPITries > 500) {
        alert("Error in finding API -- too deeply nested.");
        return null
      }
      win = win.parent
    }
    return win.API
  }
  function init() {
    if ((window.parent) && (window.parent != window)){
      API = FindAPI(window.parent)
    }
    if ((API == null) && (window.opener != null)){
      API = FindAPI(window.opener)
    }
    if (API == null) {
      alert("No API adapter found")
    } else {
      API.LMSInitialize("")
    }
  }
  function finish() {
    if (API != null) {
      API.LMSFinish("")
    }
  }
</script>

<title></title>
</head>
<body onload="init()" onunload="finish()">
<h1>Hello world</h1>
</body>
</html>

Now, in my activity, I will load a webview with a HTML file which uses
this JS.
Is there a way to bind a java object from my application to satisfy
FindAPI function.
So that window.parent gets binded to my webviewclient or  a java
object from my project in which I plan to have LMSInitialize and
LMSFinish functions.

Is there a possible solution for this within android?

Thanks.

On Oct 15, 1:58 pm, Mark Murphy <[EMAIL PROTECTED]> wrote:
> Rubicks wrote:
> > My activity has a webview . I will be leading some html pages on that
> > webview which includes some JavaScript functions. I have a need to
> > send some data from webview to my java application based on some user
> > actions using javaScript functions. Is it possible or how can I do
> > it?
>
> You can try using WebView#addJavascriptInterface() to expose a Java
> object (via reflection, I assume) to your WebView under a JavaScript
> namespace.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 1.3 Published!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to