title: WebView: Uncaught ReferenceError: Android is not defined
body: <p>I am creating a WebView with code rather than loading via an XML layout.  The webview appears to be created properly, but I am seeing the errors:</p>
  
  <pre><code>W/AwContents( 4564): nativeOnDraw failed; clearing to background color.
  I/chromium( 4564): [INFO:CONSOLE(1)] "Uncaught ReferenceError: Android is not defined", 
  ...
  </code></pre>
  
  <p>If I put the WebView in my XML layout, I don't get these errors.  Notice that, if the script runs, it will change the onLoadEvent field value from "no" to "yes.  That is happening, so evidently the script is running.  It is not fetching the user name and password, though, indicating that "Android" is not defined.</p>
  
  <p>I have also tried executing addView() before webView.loadData(); same errors.</p>
  
  <p>Here's the code that creates the WebView:</p>
  
  <pre><code>  @SuppressLint("SetJavaScriptEnabled")
    private void onOk ()
    {
      Log.d ("RegTest", "onOk");
      webView = new WebView (this);
      webView.setLayoutParams (new ViewGroup.LayoutParams(
          ViewGroup.LayoutParams.MATCH_PARENT,
          ViewGroup.LayoutParams.MATCH_PARENT));    
      WebSettings webSettings = webView.getSettings();
      webSettings.setJavaScriptEnabled (true);
      CharSequence cs = readAsset ("input_form");
      webView.loadData (cs.toString(), "text/html", "UTF-8");
  
      contentView.addView (webView);
    }
  </code></pre>
  
  <p>And here are snips of "input_form", which is the source for the WebView content:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;head&gt;
    ...
    &lt;script type="text/javascript"&gt;
      function onLoadValues ()
      {
        document.getElementById ("onLoadEvent").value = "yes";
        document.getElementById ("FullName").value = Android.getFullName();
        document.getElementById ("EmailAddress").value = Android.getEmailAddr(); 
      }
    &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body onload="onLoadValues()"&gt;
    &lt;form name="catwebformform52174" method="post" ...&gt;
      &lt;fieldset&gt;
        &lt;div class="pure-control-group"&gt;
          &lt;label for="onLoadValues"&gt;onLoadEvent&lt;/label&gt;
          &lt;input id="onLoadEvent" name="onLoadEvent" type="text" placeholder="no"&gt;
        &lt;/div&gt;
        &lt;div class="pure-control-group"&gt;
          &lt;label for="FullName"&gt;Name&lt;/label&gt;
          &lt;input id="FullName" name="FullName" type="text" placeholder="Name"&gt;
        &lt;/div&gt;
        &lt;div class="pure-control-group"&gt;
          &lt;label for="EmailAddress"&gt;Email Address&lt;/label&gt;
          &lt;input id="EmailAddress" name="EmailAddress" type="email" placeholder="Email Address"&gt;
        &lt;/div&gt;
      &lt;/fieldset&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>