Code example for WebView: Displaying web pages

Methods: getUrlloadUrl

0
 
  private String executeJavascriptInWebView(final String script) {
    result = null;
    ServerInstrumentation.getInstance().runOnUiThread(new Runnable() {
      public void run() { 
        if (webview.getUrl() == null) {
          return; 
        } 
        webview.loadUrl("javascript:" + script);
      } 
    }); 
    long timeout = System.currentTimeMillis() + 60000; /*
                                                        * how long to wait to allow the script to 
                                                        * run? This could be arbitrarily high for 
                                                        * some users... setting extremely high for 
                                                        * now (1 min) 
                                                        */ 
    synchronized (syncObject) {
      while (result == null && (System.currentTimeMillis() < timeout)) {
        try { 
          syncObject.wait(2000);