android: i want to wait for WebView finishing excuting script
<p>i want to get the html including javascript from web.</p>

<p>my code is like this</p>

<p>public class HogeActivity extends Activity {</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final WebView webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new HogeWebViewClinet());
    webView.addJavascriptInterface(new WebViewLogger(), "webViewLogger");
    webView.loadUrl("http://www.example.com/");
    setContentView(webView);
}

class HogeWebViewClinet extends WebViewClient {
    @Override public void onPageFinished(WebView view, String url) {
        view.loadUrl("javascript:window.webViewLogger.log(document.documentElement.outerHTML);");
    }
}

class WebViewLogger {
    public void log(String str) {
        Log.d("webViewLogger", str);
    }
}
</code></pre>

<p>}</p>

<p>the URL in this code including javascript.</p>

<p>i override onPageFinished to wait for finishing process and put result at WebViewLogger class.</p>

<p>i must wait for excuting javascript,but onPageFinish waits only to load page ,dont wait to execute javascript.</p>

<p>what is the best way to wait to execute javascript?</p>
