title: Understanding Android's webview addjavascriptinterface
body: <p>I know that to interact from Javascript to Java you have to inject a Java object using the addjavascriptInterface method in webview.</p>
  
  <p>Here is the problem I am facing.</p>
  
  <ol>
  <li><p>I register a java object using <code>addJavascriptInterface</code> method to be available in my JS.</p></li>
  <li><p>I inject few JS in the webview using <code>webview.loadURL("javascript:XXX");</code></p></li>
  <li><p>I send a JS event when I am done with injecting the JS.</p></li>
  </ol>
  
  <p>The problem is that if immediately after step 1, if I execute the following Javascript: </p>
  
  <pre><code>mWebView.loadUrl("javascript:if(window.myobject) console.log('myobject found---------'); else {console.log('myobject not found----');}");
  </code></pre>
  
  <p>I get "myobject not found" in my console's log.</p>
  
  <p>I want to know that if there is some time before I can access my object and if so, how do I get to know how much time should I wait to call my object?</p>