Example usage for android.webkit WebSettings setJavaScriptEnabled

List of usage examples for android.webkit WebSettings setJavaScriptEnabled

Introduction

In this page you can find the example usage for android.webkit WebSettings setJavaScriptEnabled.

Prototype

public abstract void setJavaScriptEnabled(boolean flag);

Source Link

Document

Tells the WebView to enable JavaScript execution.

Usage

From source file:Main.java

/**
 * <p>Configures basic settings of the webView (Javascript enabled, DOM storage enabled,
 * database enabled).</p>//from  w  w  w  . j a  v a  2 s  . co m
 *
 * @param webView The shared webView.
 */
@SuppressLint("SetJavaScriptEnabled")
private static void configureWebViewDefaults(WebView webView) {
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);

    webView.setWebChromeClient(new WebChromeClient());
}

From source file:com.example.android.permissionrequest.PermissionRequestFragment.java

@SuppressLint("SetJavaScriptEnabled")
private static void configureWebSettings(WebSettings settings) {
    settings.setJavaScriptEnabled(true);
}

From source file:net.niyonkuru.koodroid.webview.BlockingWebView.java

public static BlockingWebView createInstance(Context ctx) {
    BlockingWebView view = new BlockingWebView(ctx);

    WebSettings websettings = view.getSettings();

    websettings.setJavaScriptEnabled(true);
    websettings.setDatabaseEnabled(false);
    websettings.setDomStorageEnabled(false);
    websettings.setSupportZoom(false);//ww w .  j  av a  2 s  .c  o m
    websettings.setSavePassword(false);
    websettings.setSupportMultipleWindows(false);
    websettings.setAppCacheEnabled(false);
    websettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    websettings.setBlockNetworkImage(true);

    return view;
}

From source file:org.microg.gms.auth.login.LoginActivity.java

@SuppressLint("SetJavaScriptEnabled")
private static void prepareWebViewSettings(WebSettings settings) {
    settings.setUserAgentString(settings.getUserAgentString() + MAGIC_USER_AGENT);
    settings.setJavaScriptEnabled(true);
    settings.setSupportMultipleWindows(false);
    settings.setSaveFormData(false);/*from  w w w.j av  a 2s .  c  o  m*/
    settings.setAllowFileAccess(false);
    settings.setDatabaseEnabled(false);
    settings.setNeedInitialFocus(false);
    settings.setUseWideViewPort(false);
    settings.setSupportZoom(false);
    settings.setJavaScriptCanOpenWindowsAutomatically(false);
}

From source file:com.rizal.lovins.smartkasir.fragment.HomeAdminFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*from   www.  j ava 2s .  c o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home_admin, container, false);

    WebView mWebView = (WebView) view.findViewById(R.id.webViewAdmin);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mWebView.getSettings().setBuiltInZoomControls(false);
    mWebView.getSettings().setDisplayZoomControls(false);
    mWebView.loadUrl("file:///android_asset/license/index.html");

    return view;
}

From source file:com.rizal.lovins.smartkasir.fragment.HomeKasirFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override//from   ww  w  . ja va2 s  .  c  om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home_kasir, container, false);

    WebView mWebView = (WebView) view.findViewById(R.id.webViewKasir);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mWebView.getSettings().setBuiltInZoomControls(false);
    mWebView.getSettings().setDisplayZoomControls(false);
    mWebView.loadUrl("file:///android_asset/license/index_kasir.html");

    return view;
}

From source file:MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    WebView webview = new WebView(this);
    setContentView(webview);//from w ww  . j  av  a 2s.  com
    webview.loadUrl("https://www.java2s.com/");
    webview.setWebViewClient(new WebViewClient());

    WebSettings webSettings = webview.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
}

From source file:com.elkriefy.android.apps.chubbytabby.activity.WebViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);
    mWebView = (WebView) findViewById(R.id.web_view);
    String url = getIntent().getStringExtra(EXTRA_URL);
    mWebView.setWebViewClient(new WebViewClient());
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mWebView.loadUrl(url);//from w ww .ja  va2 s.  c o m
    setupActionBar(url);
}

From source file:com.amazonaws.devicefarm.android.referenceapp.Fragments.LocalWebView.java

/**
 * Sets up a web view// w  ww  . j a v a2 s . co m
 */
private void setUpWebView() {
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    webView.loadUrl(getString(R.string.local_web_view_url));
}

From source file:com.toan_itc.tn.Fragment.WebviewFragment.java

@Nullable
@Override/*from   w  w  w  .  j a  v a2 s.  c o m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_details, container, false);
    webView = (WebView) view.findViewById(R.id.webview);
    String url = getArguments().getString(EXTRA_URL);
    Log.wtf("url=", url);
    webView.setWebViewClient(new WebViewClient());
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.loadUrl(url);
    return view;
}