Code example for WebView: Displaying local web pages

Methods: addJavascriptInterfacegetSettingsloadDatasetWebViewClient

0
        try { 
            runTestOnUiThread(new Runnable() {
                @Override 
                public void run() { 
                    WebView webView = activity.getWebView();
                    webView.addJavascriptInterface(object, name);
                    webView.getSettings().setJavaScriptEnabled(true);
                    webView.setWebViewClient(mWebViewClient);
                    webView.loadData("<!DOCTYPE html><title></title>", "text/html", null);
                } 
            }); 
            mWebViewClient.waitForOnPageFinished();
        } catch (Throwable e) {
            throw new RuntimeException("Failed to set up WebView: " + Log.getStackTraceString(e));
        } 
    } 
 
    protected void executeJavaScript(final String script) throws Throwable {
        runTestOnUiThread(new Runnable() {
            @Override 
Stop searching for code, let great code find you!  Add Codota to your java IDE