enable JavaScript in WebView - Android android.webkit

Android examples for android.webkit:WebView

Description

enable JavaScript in WebView

Demo Code

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;

public class Main{

    /**//from   w  w w  . j a v a 2  s . com
     * Enable java script.
     *
     * @param webView
     *     the web view
     * @param enabled
     *     the enabled
     */
    @SuppressLint("SetJavaScriptEnabled")
    public static void enableJavaScript(WebView webView, boolean enabled) {
        if (webView != null) {
            webView.getSettings().setJavaScriptEnabled(enabled);
        }
    }

}

Related Tutorials